daily pastebin goal
30%
SHARE
TWEET

PS netsh.exe

Neantro Jun 15th, 2016 (edited) 1,464 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Make a list with all WiFi SSID's and passwords stored locally on Windows OS.
  2.  
  3. $output = netsh.exe wlan show profiles
  4. $profileRows = $output | Select-String -Pattern 'All User Profile'
  5. $profileNames = New-Object System.Collections.ArrayList
  6.  
  7. #for each profile name get the SSID and password
  8. for($i = 0; $i -lt $profileRows.Count; $i++){
  9.     $profileName = ($profileRows[$i] -split ":")[-1].Trim()
  10.    
  11.     $profileOutput = netsh.exe wlan show profiles name="$profileName" key=clear
  12.    
  13.     $SSIDSearchResult = $profileOutput| Select-String -Pattern 'SSID Name'
  14.     $profileSSID = ($SSIDSearchResult -split ":")[-1].Trim() -replace '"'
  15.  
  16.     $passwordSearchResult = $profileOutput| Select-String -Pattern 'Key Content'
  17.     if($passwordSearchResult){
  18.         $profilePw = ($passwordSearchResult -split ":")[-1].Trim()
  19.     } else {
  20.         $profilePw = ''
  21.     }
  22.    
  23.     $networkObject = New-Object -TypeName psobject -Property @{
  24.         ProfileName = $profileName
  25.         SSID = $profileSSID
  26.         Password = $profilePw
  27.     }
  28.     $profileNames.Add($networkObject)
  29. }
  30.  
  31. $profileNames | Sort-Object ProfileName | Select-Object ProfileName, SSID, Password
  32.  
  33. #blog help source: https://blogs.technet.microsoft.com/heyscriptingguy/2015/11/23/get-wireless-network-ssid-and-password-with-powershell/
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top