else ForEach-Object Write-Log " - $_"
# Check for Windows PowerShell updates via PSWindowsUpdate module Install-Module PSWindowsUpdate -Force Get-WindowsUpdate -Category "Security Updates" -Install -AcceptAll WMF 5.1 is the final version — no newer Windows PowerShell releases. 6. Automation & CI/CD Integration # GitHub Actions example - name: Update PowerShell shell: pwsh run: | Update-PowerShell -Stable -PassThru -Force pwsh --version Scheduled task (daily update check): powershell update command
else Write-Log "Skipping PowerShell Core update (not running PS7+)" try Write-Log "Updating all PowerShell modules..." $modules = Get-InstalledModule foreach ($mod in $modules) try $oldVer = $mod.Version Update-Module -Name $mod.Name -Force -ErrorAction Stop $newVer = (Get-InstalledModule -Name $mod.Name).Version if ($newVer -gt $oldVer) Write-Log "Updated module $($mod.Name): $oldVer -> $newVer" else ForEach-Object Write-Log " - $_" # Check