我有一個簡單的工作流程並行循環,但寫入結果時發生錯誤。因爲寫入輸出是並行的。我得到的錯誤:PowerShell ForEach使用並行文件
The process cannot access the file because it is being used by another process.
這裏是我的腳本:
workflow Get-ServerServices
{
$srvlst = Get-Content C:\TEMP\srvlst.txt
foreach -parallel ($srv in $srvlst)
{
Get-Service -PSComputerName $srv | Out-File c:\temp\test.txt -Append
}
}
什麼想法?