Jump to content

wrapper for test-netconnection


iamtheky
 Share

Recommended Posts

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

 

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...