Get-ChildItem : The network path was not found



在运行power shell脚本以从多个服务器获取最大文件时,我面临此错误。有人能帮我解决这个错误吗?

脚本:

$computers = get-content -Path "D:Automation_space_checkServers.txt."
foreach($_ in (Get-WmiObject win32_volume -ComputerName $computer)){
if($_.drivetype -eq 3 -and $_.driveletter -ne $null){
Get-ChildItem "\$computer$($_.driveletter.replace(':','$'))" -force -recurse -ErrorAction silentlycontinue | select Name,DirectoryName,@{Name="size";Expression={"{0:N1}" -f($_.length/1mb)}} |
Sort Size -descending | select -first 10}}

错误:

Get-ChildItem: The network path was not found AtD: Automation_space_check Untitled3。ps1:18 char: 1+ Get-ChildItem"电脑(_.driveletter.replace美元美元 (':','$'))& ";force……+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo: NotSpecified:(:() [Get-ChildItem], IOException . ++ fulllyqualifiederror: System.IO.IOException,Microsoft.PowerShell.Commands.GetChildItemCommand

Servers.txt

Computer1
computer2
computer3
computer4
$computers = get-content -Path "D:Automation_space_checkServers.txt."
foreach($computer in  $computers) {
foreach($drive in (Get-WmiObject win32_volume -ComputerName $computer)) {
if($drive.drivetype -eq 3 -and $drive.driveletter -ne $null){
Get-ChildItem "\$computer$($_.driveletter.replace(':','$'))" -force -recurse -ErrorAction silentlycontinue | select Name,DirectoryName,@{Name="size";Expression={"{0:N1}" -f($_.length/1mb)}} |
Sort Size -descending | select -first 10
}
}
}

相关内容

最新更新