我使用Octopus進行部署。我與PowerShell腳本來控制部署的一個問題:非互動模式下的Powershell
# stops running processes
$processes = @("Notepad",
"Firefox")
foreach ($process in $processes)
{
$prc = Get-Process -Name $process -ErrorAction SilentlyContinue
if (-not($prc -eq $null))
{
Write-Host "Stopping " $prc.ProcessName
Stop-Process -InputObject $prc -ErrorAction SilentlyContinue
}
}
我試圖阻止的程序是不是你在上面的腳本中看到的,但它們代表什麼,我試圖做的。現在我遇到的問題是,它在一臺服務器上運行良好,但不在另一臺服務器上運行。如果它不起作用,我會收到錯誤消息:
停止進程:Windows PowerShell處於NonInteractive模式。閱讀和提示功能不可用。
該工作的腳本在Powershell 3.0上運行,該功能在Powershell 2.0上不起作用。我無法到處升級到Powershell 3.0,因爲舊服務器與Windows Server 2003一起運行。我怎樣才能使它在PS 2.0上工作?
你能從2.0版服務器上發佈'get-executionpolicy'和'$ confirpreference'的值嗎? –
get-executionpolicy RemoteSigned $ confirmpreference 沒有爲$ confirmpreference輸出。 – tobre
Ops,我的錯字:$ confirmpreference ... –