Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Whenever I use Get-Service with a user that does not have access on the target server it takes a large amount of time to timeout. This is results in an increased amount of time necessary to run a script

Is there a way to find out if a user has access on the target sever? I want to use that kind of functionality in my script to decrease the amount of system resources necessary.

Any and all help is greatly appreciated.

share|improve this question
    
Access to a server in terms of permissions or just connectivity across the network? –  Christopher Sep 6 '11 at 20:56
add comment

1 Answer

up vote 1 down vote accepted

Test-Connection (TechNet article here) sends ICMP packets to check for response across the network. It is a PowerShell 2.0 cmdlet.

So if you do:

Test-Connection -count 2 -quiet

it will send 2 ICMP packets and return $true if any are successful or $false if all are dropped.

share|improve this answer
    
thank a lot. i was struggling with it and was looking to timeout wmi calls –  Nikhil S Sep 7 '11 at 7:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.