【发布时间】:2021-10-26 09:17:27
【问题描述】:
在运行我的 power shell 脚本以从多个服务器获取最大文件时,我遇到了这个错误。谁能帮我解决这个错误。
脚本:
$computers = get-content -Path "D:\Automation_space_check\Servers.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 : 未找到网络路径 D:\Automation_space_check\Untitled3.ps1:18 char:1 + Get-ChildItem "\$computer$($_.driveletter.replace(':','$'))" -force ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-ChildItem], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.GetChildItemCommand
Servers.txt
Computer1
computer2
computer3
computer4
【问题讨论】:
标签: powershell