- File changed:
Install-RemoteMSI.ps1 - Purpose: validate/fix command and flag compatibility across Windows PowerShell 5.1 and PowerShell 7, and remove fragile runtime behavior.
- Replaced invalid/host-specific
Test-Connectionusage that depended on unsupported parameter sets. - Added a compatibility-first flow:
- Try
Test-NetConnection -ComputerName <host> -Port 5985 -InformationLevel Quietwhen available. - Fallback to
.NET TcpClientconnect probe on port5985. - If TCP check fails/unavailable, fallback to
Test-Connectionwith dynamic parameter detection:ComputerName(PS5.1) vsTargetName(PS7)TimeoutSecondsvsTimeoutMillisecondswhen present.
- Try
- Result: avoids invalid flag usage while preserving intended behavior on both PowerShell versions.
- In the
.NET TcpClientpath, movedEndConnect()handling into cleanup so resources are finalized consistently. - Added guarded cleanup around
AsyncWaitHandle.Close(). - Result: avoids leaked/unfinished async operation state during timeout/failure paths.
- Fixed 3 occurrences of:
Write-Host "n" + ('=' * 70)`
- Updated to:
Write-Host ("n" + ('=' * 70))`
- Result: ensures the full intended separator string is actually emitted.
- In
Test-DomainCredential, added:Add-Type -AssemblyName System.DirectoryServices.AccountManagement -ErrorAction SilentlyContinue
- Result: improves reliability where auto-loading may not occur predictably.
- Updated reboot state probe logic in both sequential and parallel execution paths:
- Old:
Get-WmiObject ...with WMI-specificPSBase.Propertiescheck. - New: prefer
Get-CimInstance -ClassName Win32_OperatingSystem, fallback toGet-WmiObject -Class .... - Property evaluation simplified to direct
RebootRequiredcheck.
- Old:
- Result: compatibility with PS7 and cleaner object handling across CIM/WMI outputs.
- PowerShell parser checks executed successfully after edits:
[ScriptBlock]::Create((Get-Content -Path "Install-RemoteMSI.ps1" -Raw))returned parse success.
- Additional local command metadata checks were used during implementation to verify parameter-set differences between PS5.1 and PS7.
- No functional scope expansion was introduced; all edits were compatibility and correctness fixes for existing behavior.
- No unrelated source files were modified by these implementation changes.