From 2ca76f7617aaf7a4f7ce4602836d43dd229367af Mon Sep 17 00:00:00 2001 From: Mathew Date: Wed, 30 Oct 2024 16:52:19 +0000 Subject: [PATCH] Update opera_roomlist_creator.ps1 --- opera_roomlist_creator.ps1 | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/opera_roomlist_creator.ps1 b/opera_roomlist_creator.ps1 index 7c74ea7..d31bbd5 100644 --- a/opera_roomlist_creator.ps1 +++ b/opera_roomlist_creator.ps1 @@ -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 +$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" \ No newline at end of file