在W2K3上的Start-Job Scriptblock中执行PS脚本失败

时间:2012-10-02 21:32:23

标签: powershell powershell-v2.0 powershell-remoting

我正在尝试执行下面的脚本块。这在Win 7上工作正常但在W2K3上永远不会成功。工作处于永久运行状态。知道为什么吗?

$Scriptblock = {
    Add-Content c:\temp\test.txt -Value "Starting..."
    $processes = c:\temp\test.ps1
    Add-Content c:\temp\test.txt -Value $processes
    Add-Content c:\temp\test.txt -Value "finished"
}

If (-not(Test-Path "c:\temp\test.ps1")){Add-Content c:\temp\test.ps1 -Value "get-process"}
Start-Job -ScriptBlock $Scriptblock

0 个答案:

没有答案