0

I want to read the state of a wifi adapter. For example I want to know if the wifi device connected to an access point.

Is it possible to do it with powershell?

1 Answer 1

3

Something like this might do it

Add-Type -TypeDefinition @"
   public enum NetConnectionStatus
   {
        Disconnected=0,
        Connecting=1,
        Connected=2,
        Disconnecting=3,
        Hardware_Not_present=4,
        Hardware_disabled=5,
        Hardware_malfunction=6,
        Media_disconnected=7,
        Authenticating=8,
        Authentication_succeeded=9,
        Authentication_failed=10,
        Invalid_address=11,
        Credentials_required=12
   }
"@

$Adaptors = Get-WmiObject -class win32_networkadapter -filter "Name like '%wireless%'" | select name, deviceID, NetConnectionStatus

foreach ($adaptor in $Adaptors){
    "$($adaptor.deviceID) : $($adaptor.name) : $([NetConnectionStatus]::GetName([NetConnectionStatus],$adaptor.NetConnectionStatus))"
}
Sign up to request clarification or add additional context in comments.

2 Comments

It doesn't answer though what wireless profile it is connected to akin to what netsh wlan show interfaces reports.
I know this is old but if you reread your question you didnt ask for the wireless profile. You asked what is the State of the adapter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.