【发布时间】:2013-02-26 18:56:07
【问题描述】:
我正在尝试使用 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 字符:1 + 获取内容-路径'\$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 字符:1 + 获取内容 -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
【问题讨论】: