[Console]::OutputEncoding = [Text.Encoding]::UTF8 $ErrorActionPreference = 'Stop' function Section($title) { Write-Host '' Write-Host ('=' * 8) $title ('=' * 8) -ForegroundColor Green } function StatusUpdate($message) { Write-Host "āœ… $message" -ForegroundColor Green } function WarningUpdate($message) { Write-Host "āš ļø $message" -ForegroundColor Yellow } Write-Host "Fixing remaining WinRM configuration issues..." -ForegroundColor Cyan Section "Fix Allow Unencrypted Setting" try { cmd /c 'winrm set winrm/config/service @{AllowUnencrypted="true"}' | Out-Null StatusUpdate "Allow unencrypted communication enabled" } catch { WarningUpdate "Failed to set AllowUnencrypted: $($_.Exception.Message)" } Section "Enable WinRM Firewall Rules" try { Enable-NetFirewallRule -DisplayGroup "Windows Remote Management" -ErrorAction SilentlyContinue StatusUpdate "WinRM firewall rules enabled" # Show enabled WinRM rules $winrmRules = Get-NetFirewallRule -DisplayGroup "*Remote Management*" | Where-Object Enabled -eq $true Write-Host "Enabled WinRM firewall rules:" -ForegroundColor Yellow $winrmRules | Select-Object DisplayName, Direction, Action | Format-Table -AutoSize } catch { WarningUpdate "Firewall rule configuration: $($_.Exception.Message)" } Section "Verify Settings" try { Write-Host "Current WinRM Service Configuration:" -ForegroundColor Yellow winrm get winrm/config/service Write-Host "`nCurrent Authentication Settings:" -ForegroundColor Yellow winrm get winrm/config/service/auth } catch { WarningUpdate "Could not retrieve configuration: $($_.Exception.Message)" } Section "Final Connection Test" try { $testSession = New-PSSession -ComputerName localhost -ErrorAction Stop Remove-PSSession $testSession -ErrorAction SilentlyContinue StatusUpdate "Final local WinRM test successful" } catch { WarningUpdate "Final test failed: $($_.Exception.Message)" } Write-Host "`nšŸŽ‰ WinRM configuration fixes completed!" -ForegroundColor Green