我正在尝试使用 Powershell 3.0 针对 multilpe 服务器运行以下命令,但由于某种原因,我发现路径不存在......即使它存在?
有任何想法吗?
代码:
clear
$computer = Get-Content -path c:\temp\servers.txt
foreach ($computer1 in $computer){
Write-Host $computer1
Get-Content -Path '\\$computer1\C$\Program Files\BMC Software\BladeLogic\RSCD\rscd.log' -Tail 10
}
错误:
SV191267 获取内容:找不到路径“\$computer1\C$\Program Files\BMC Software\BladeLogic\RSCD\rscd.log”,因为它不存在。在 C:\Users\gaachm5\AppData\Local\Temp\e4651274-dcab-4a87-95a6-0f11437a7187.ps1:7 char:1 + Get-Content -Path '\$computer1\C$\Program Files\BMC Software\ BladeLogic\RSCD\rs ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (\$computer1\C $...c\RSCD\rscd.log:String) [Get-Content], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
SV193936 获取内容:找不到路径“\$computer1\C$\Program Files\BMC Software\BladeLogic\RSCD\rscd.log”,因为它不存在。在 C:\Users\gaachm5\AppData\Local\Temp\e4651274-dcab-4a87-95a6-0f11437a7187.ps1:7 char:1 + Get-Content -Path '\$computer1\C$\Program Files\BMC Software\ BladeLogic\RSCD\rs ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (\$computer1\C $...c\RSCD\rscd.log:String) [Get-Content], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand