테스트-연결이 간헐적으로 자원 오류의 부족으로 실패 자원 부족으로 실패 당신이 목록을 테스트 할 때파워 쉘 테스트 - 연결 인해
test-connection : Testing connection to computer 'SOMESERVER' failed: Error due to lack of resources
At line:1 char:45
+ ... ($server in $ServersNonProd.Name) { test-connection $server -Count 1}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (SOMESERVER:String) [Test-Connection], PingException
+ FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand
결과, 그것은 안정적이고 상당히 쓸모가 아니다 컴퓨터가 루프에 있습니다. 이 기능을 안정적으로 사용하기위한 수정 프로그램, 대안 또는 해결 방법이 있습니까?
이것은 현재 해결책이지만 아직 충분히 안정적이지 않습니다 (때때로 그들은 5 회 연속 실패합니다). 모든 지연과 재 시도 때문에 영원히 걸립니다.
$Servers = Import-CSV -Path C:\Temp\Servers.csv
$result = foreach ($Name in $Servers.FQDN) {
$IP = $null
if (Resolve-DNSName $Name -ErrorAction SilentlyContinue) {
$IP = (Test-Connection -Count 1 -ComputerName $Name -ErrorAction SilentlyContinue).IPv4Address
if ($IP -eq $null) {
Start-Sleep -Milliseconds 100
$IP = (Test-Connection -Count 1 -ComputerName $Name -ErrorAction SilentlyContinue).IPv4Address
}
if ($IP -eq $null) {
Start-Sleep -Milliseconds 200
$IP = (Test-Connection -Count 1 -ComputerName $Name -ErrorAction SilentlyContinue).IPv4Address
}
if ($IP -eq $null) {
Start-Sleep -Milliseconds 300
$IP = (Test-Connection -Count 1 -ComputerName $Name -ErrorAction SilentlyContinue).IPv4Address
}
if ($IP -eq $null) {
Start-Sleep -Milliseconds 400
$IP = (Test-Connection -Count 1 -ComputerName $Name -ErrorAction SilentlyContinue).IPv4Address
}
}
new-object psobject -Property @{FQDN = $Name; "IP Address" = $IP}
}
정상적인 핑 (PING.EXE는)마다 작동하므로 좋은 방법이 있다면 PowerShell로 (최대 호스트 또는 아래로, 어떤 IP가 응답) 있다는 분석에 이상적인 솔루션처럼 보인다,하지만 할 나는 그저 효과가있는 것을 필요로하므로, 나는 아이디어에 열심입니다.
음, 꽤 이상하게 보입니다. 주위를 돌아 다니려면 do-while 루프를 구현할 수 있지만 근본 원인을 해결하는 것이 좋습니다. 너는 그걸 고치려고 한 것처럼? '/ sfc scannow' 적어도? 아무것도?PS5로 업그레이드 하시겠습니까? – 4c74356b41
iirc 재부팅이 일반적으로이를 수정하지만 (실제로 잘못되었을 수 있으며, 1 년이 넘었습니다) 실제로 PS 버전을 실행하고 있습니까? PSv2에만 영향을 미치는 이슈를 기억하는 것 같습니다 (다시 말하지만, 잘못 리 시트 될 수 있습니다) –
'-Quiet' 또는'-ErrorAction SilentlyContinue' 또는 둘 다를 사용하는 것은 어떻습니까? 이것은 원격 호스트에서 'WMI' 오류로 인해 발생할 수 있습니다. 그리고 '-Count 1'은 항상 신뢰할 만하지는 않습니다. 내 평범한 줄 :'(Test-Connection $ host -Quiet -Count 2 -EA 0) {# ...}'은 매력처럼 작동합니다. – sodawillow