networking - PowerShell operation on UNC hangs too long -
$to="\\server\share\folder" if(!(test-path $to)) { ... }
if server offline (resolved name no pings), phone call test-path never returns (in narrow minded understanding of script time). takes long fail. much anticipated result false after making toasts butter, finding no coffee, running out purchase some, waiting water boil 1 time again , finding toasts cold. returning screen , seeing appear right there...
same path classic dos dir fails expected after realistic time:
dir "\\server\share\folder" says "the network path not found." in less 3 minutes!
this behavior of ps breaks script.
to precise
$t0 = get-date; test-path "\\server\share\folder"; $t1 = get-date; ($t1-$t0).totalseconds gave me
false 595.2214875 hint: replace server resolving local net offline pc name
ah question is: 1) how deal this? 2) heck problem there?
update: timings same when using offline ip address. dns out of game.
update2: wonder, experiencing same wasted time? tried on 64bit w2k8r2 server , there no issues there. phone call returns in 30s max. problem on 32bit windows xp pc.
thanks, rob
i can't simulate scenario, have suggestion. seek pinging server first effort create connection.
$(test-connection -computername server -erroraction silentlycontinue -count 1).statuscode this command homecoming 0 if ping successful, can utilize in conditional statement.
networking powershell timeout unc
No comments:
Post a Comment