Update opera_roomlist_creator.ps1

This commit is contained in:
Mathew 2024-10-30 16:52:19 +00:00
parent de4a0e1f9d
commit 2ca76f7617

View File

@ -77,11 +77,33 @@ foreach ($room in $roomNodes) {
$roomData += [PSCustomObject]@{
RoomID = $roomID
RoomType = $roomType
Rflag = 0
RoomDescription = $roomDescription
RoomTypeCode = $roomType
TelNo1 = ""
TelNo2 = ""
}
}
# Export to CSV
$roomData | Export-Csv -Path "RoomStatusReport.csv" -NoTypeInformation -Encoding UTF8
# The below parameter is used for version 7 of powershell for the above command
# -UseQuotes never
Write-Output "Room status data has been saved to RoomStatusReport.csv"
# because we cannot remove the quote marks due to the powershell version, we use the below command to remove them
(Get-Content .\RoomStatusReport.csv -Encoding UTF8) | % {$_ -replace '"',''} | Select-String -Pattern "^\d\d\d," | out-File .\RoomStatusReport.csv -Encoding utf8
Write-Output "removed Quotes"
#adding the headers back in
$header = 'RoomID,Rflag,RoomDescription,RoomTypeCode,TelNo1,TelNo2'
$data = Get-Content .\RoomStatusReport.csv -Encoding UTF8
$header | Set-Content .\RoomStatusReport.csv -NoNewline
$data | Add-Content .\RoomStatusReport.csv
Write-Output "added headers back in"