Reputation: 21
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?
Upvotes: 0
Views: 3293
Reputation: 6860
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))"
}
Upvotes: 3