Deployment_scripts/pmsdetailsconverter.ps1

42 lines
2.0 KiB
PowerShell

# Save this as "SaveHotelConfig.ps1"
# Prompt the user for the hotel data input
$hotelData = Read-Host -Prompt "Please paste the hotel configuration data"
# Split the input into lines and create a hashtable to store key-value pairs
$hotelConfig = @{}
# Process each line of the input data
$hotelData -split "`n" | ForEach-Object {
# Split each line by colon and trim whitespace
$line = $_.Trim()
if ($line -match "^(.*?):(.*)$") {
$key = $matches[1].Trim()
$value = $matches[2].Trim()
# Map the parsed keys to corresponding field names in JSON
switch ($key) {
"System" { $hotelConfig["System"] = $value }
"Site ID" { $hotelConfig["SiteID"] = $value }
"User Name" { $hotelConfig["UserName"] = $value }
"Password" { $hotelConfig["Password"] = $value }
"Site URL" { $hotelConfig["SiteURL"] = $value }
"Time zone" { $hotelConfig["TimeZone"] = $value }
"Chain Code" { $hotelConfig["ChainCode"] = $value }
"Hotel Code" { $hotelConfig["HotelCode"] = $value }
"Domain" { $hotelConfig["Domain"] = $value }
"Origin EntityID" { $hotelConfig["OriginEntityID"] = $value }
"Origin SystemType" { $hotelConfig["OriginSystemType"] = $value }
"Destination EntityID" { $hotelConfig["DestinationEntityID"] = $value }
"Destination SystemType" { $hotelConfig["DestinationSystemType"] = $value }
"Site Username" { $hotelConfig["SiteUsername"] = $value }
"Site Password" { $hotelConfig["SitePassword"] = $value }
"Cloud PMS" { $hotelConfig["CloudPMS"] = $value }
}
}
}
# Save the hotel configuration to a JSON file
$hotelConfig | ConvertTo-Json | Set-Content -Path "HotelConfig.json" -Encoding UTF8
Write-Output "Hotel configuration saved to HotelConfig.json"