$raw = netsh wlan show network mode=Bssid$ssids= $raw | Select-string-pattern'ssid\b'| Select-string-pattern'\bbssid\s[^1]\b'-notmatch | foreach-Object {$_. ToString (). PadRight ( One) +'_'#有些扫描出来的SSID没有名字, so I'll simply have all SSOD names followed by an underscore to ensure subsequent formatting is correct} $ssids 2= $ssids-Split '\b\s\d{1,}\s{1,}[:]\s+\b'|Select-string-pattern'ssid\b'-notmatch #分割字符, SSID | <SSIDNAME> | BSSID | <mac address> for($i =0; $i-lt $ssids 2. Count; $i = $i +2) {# $ssids 2[$i]. ToString (). Substring (0, $ssids 2[$i]. ToString (). length-1) # $ssids 2[$i+1]. ToString (). Substring (0, $ssids 2[$i +1]. ToString (). length-1) [Pscustomobject]@{ssidname= $ssids 2[$i]. ToString (). Substring (0, $ssids 2[$i]. ToString (). length-1); macaddress= $ssids 2[$i +1]. ToString (). Substring (0, $ssids 2[$i +1]. ToString (). length-1)} #| Export-csv-path ('f:\ ' + (get-date). Hour.tostring () + (get-date). Minute.tostring () + (get-date). Minute.tostring () +'. csv')-encoding default-append-notypeinformation}
Capture the SSID name and MAC address and then reshape the output to text (how to format plain text content into PowerShell-friendly format:)