我正在使用PowerShell查詢遠程計算機C驅動器上的文件,如果文件存在狀態爲「映像已完成」,它應該運行其他檢查。檢查遠程計算機上的文件中的文本
$filetofind = Get-Content C:\Image.log
#Get the list down to just imagestatus and export
foreach ($line in $filetofind)
{
$file = $line.trim("|")
echo $file >> C:\jenkins\imagestatus.txt
}
但是,當我運行下面的命令我得到的錯誤。 任何人都可以幫忙嗎?
Get-Content : Cannot find path 'C:\Image.log' because it does not exist. At line:18 char:15 + $filetofind = Get-Content C:\Image.log + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Image.log:String) [Get-Content], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
使用的測試路徑,以確保文件是存在的 –
我想,以確保文件是存在的,需要讀取文件來檢查image.log文件更新狀態與其他檢查進行。如何可以在這裏修復 – SNair