Initial commit

This commit is contained in:
2026-04-24 17:41:53 +08:00
commit 7105e8b165
94 changed files with 8141 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
[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