# 结束卡住的迁移脚本(Restart-Service Nginx 挂死) $ErrorActionPreference = "Continue" Get-CimInstance Win32_Process -Filter "Name='powershell.exe'" | ForEach-Object { if ($_.CommandLine -and ($_.CommandLine -match 'migrate_to_wwwroot|Restart-Service')) { Write-Output "KILL_PS=$($_.ProcessId)" Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue } } # Restart-Service 卡住时服务控制也可能僵住;先杀 nginx 进程便于 bounce Get-Process nginx -ErrorAction SilentlyContinue | ForEach-Object { Write-Output "KILL_NGINX=$($_.Id)" Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue } Write-Output "KILL_DONE"