Sign in to follow this  
Followers 0
iamtheky

wrapper for test-netconnection

1 post in this topic

I wouldnt usually post a snippet that is just a wrapped one line Powershell command, but I've used it more than once now, you may too.

msgbox(0, '' , _TestConnection())

Func _TestConnection($sComp = "")

$iPid = run('powershell Test-NetConnection ' & $sComp & ' -InformationLevel Quiet'  , @WindowsDir , @SW_HIDE , 0x2)

$sOutput = ""

 While 1
    $sOutput &= StdoutRead($iPID)
        If @error Then
            ExitLoop
        EndIf
 WEnd


$bRtn = stringstripws($sOutput , 8) = "True" ? 1 : 0

return $bRtn

EndFunc

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0