Tuesday, August 7, 2012

BSSID in Windows XP using Powershell

Note: If you don't know what BSSID is, you mostly need to know that it's the MAC address of the Access Point you're connected to.

Have you ever tried to get the BSSID in Windows XP? It's kind of difficult to do it, specially when all the Google results end up showing things with netsh wlan command. netsh wlan is part of a newer version than the one in Windows XP. It comes in Windows Vista and above. However that's the fastest way to find out which BSSID you're using.

Here's a workaround I created with Powershell:

  1. $wmi = Get-WmiObject -class "MSNdis_80211_BaseServiceSetIdentifier" -namespace "root\WMI" -comp $env:computername  
  2. $mac = $wmi[0].Ndis80211MacAddress  
  3. $BSSID = ""  
  4. foreach ($num in $mac) {   
  5.     $digit = [convert]::ToString($num, 16)  
  6.     if ($digit.length -eq 1) {   
  7.         $digit = "0" + $digit.ToString()   
  8.         }  
  9.     $BSSID = $BSSID + $digit  
  10. }  
  11. Write-Host " BSSID: $BSSID " -BackgroundColor Black -ForegroundColor Yellow  


No comments:

Post a Comment