What is the installation method of your PatchMon server?
Proxmox-community script
What is the version of your PatchMon server?
2.0.2
Affected OS:
Windows Server / Windows Client
PowerShell: Windows PowerShell 5.1 / powershell.exe
Description:
The Windows agent uninstall command generated by the PatchMon GUI downloads a PowerShell script from:
/api/v1/hosts/remove?os=windows
The downloaded script fails with parser errors when executed via Windows PowerShell 5.1. The issue appears to be caused by the script being saved as UTF-8 without BOM while containing emojis / Unicode characters in Write-Host output.
Windows PowerShell 5.1 may interpret such files as ANSI/Windows-1252, which corrupts Unicode byte sequences and leads to invalid PowerShell syntax.
Steps to reproduce
- Install the Windows agent using the generated install command from PatchMon 2.0.2.
- Copy the Windows uninstall command from the PatchMon GUI.
- Download and run the generated removal script:
powershell.exe -ExecutionPolicy Bypass -File "$env:TEMP\patchmon-remove.ps1"
Expected behavior
The script should run successfully and uninstall the Windows agent.
Actual behavior:
The script fails with parser errors similar to:
- Unexpected token "}" in expression or statement.
- The string is missing the terminator: '.
- The Try statement is missing its Catch or Finally block.
Additional context
Example errors:
C:\Users<user>\AppData\Local\Temp\patchmon-remove.ps1:81 char:9
Unexpected token "}" in expression or statement.
C:\Users<user>\AppData\Local\Temp\patchmon-remove.ps1:168 char:93
The string is missing the terminator: '.
- The Linux agent uninstall works correctly.
- The problem seems specific to the generated Windows removal script.
Workaround:
Removing the emojis / Unicode symbols from the script output makes the script run successfully.
Saving the script as UTF-8 with BOM may also help, but the safer fix would probably be to avoid emojis / non-ASCII characters in Windows PowerShell scripts generated for powershell.exe compatibility.
Suggested fixes:
- Generate the Windows uninstall script as UTF-8 with BOM, or
- remove emojis / non-ASCII characters from generated Windows PowerShell scripts, or
- use PowerShell 7 compatible execution instructions explicitly.
What is the installation method of your PatchMon server?
Proxmox-community script
What is the version of your PatchMon server?
2.0.2
Affected OS:
Windows Server / Windows Client
PowerShell: Windows PowerShell 5.1 / powershell.exe
Description:
The Windows agent uninstall command generated by the PatchMon GUI downloads a PowerShell script from:
/api/v1/hosts/remove?os=windowsThe downloaded script fails with parser errors when executed via Windows PowerShell 5.1. The issue appears to be caused by the script being saved as UTF-8 without BOM while containing emojis / Unicode characters in Write-Host output.
Windows PowerShell 5.1 may interpret such files as ANSI/Windows-1252, which corrupts Unicode byte sequences and leads to invalid PowerShell syntax.
Steps to reproduce
powershell.exe -ExecutionPolicy Bypass -File "$env:TEMP\patchmon-remove.ps1"
Expected behavior
The script should run successfully and uninstall the Windows agent.
Actual behavior:
The script fails with parser errors similar to:
Additional context
Example errors:
C:\Users<user>\AppData\Local\Temp\patchmon-remove.ps1:81 char:9
Unexpected token "}" in expression or statement.
C:\Users<user>\AppData\Local\Temp\patchmon-remove.ps1:168 char:93
The string is missing the terminator: '.
Workaround:
Removing the emojis / Unicode symbols from the script output makes the script run successfully.
Saving the script as UTF-8 with BOM may also help, but the safer fix would probably be to avoid emojis / non-ASCII characters in Windows PowerShell scripts generated for powershell.exe compatibility.
Suggested fixes: