none
Saved wifi networks and passwords RRS feed

  • Question

  • Hello I am working on a script that shows all saved wifi network names as well as passwords so users can print out a list and then keep when transitioning to a new PC. So far I have a few basic commands but am still trying to get them to work together. Any help would be great. Thanks!

    $wifiname = netsh wlan show profiles
    netsh wlan show profiles name=$wifiname key=clear | export-csv C:\users\xx\desktop\wifinetworks.csv

    Thursday, April 9, 2015 2:04 PM

Answers

  • To get WiFi profiles as data use "export"

    netsh wlan export profile Hudson

    PS C:\scripts> netsh wlan export profile name="Hudson" folder="c:\test"
    
    Interface profile "Hudson" is saved in file "c:\test\Wi-Fi-Hudson.xml" successfully.
    
    PS C:\scripts> $hudson=[xml](Get-Content c:\test\Wi-Fi-Hudson.xml)
    PS C:\scripts> $hudson
    
    xml                                                                                      WLANProfile
    ---                                                                                      -----------
    version="1.0"                                                                            WLANProfile
    
    
    PS C:\scripts> $hudson.WLANProfile
    
    
    xmlns          : http://www.microsoft.com/networking/WLAN/profile/v1
    name           : Hudson
    SSIDConfig     : SSIDConfig
    connectionType : ESS
    connectionMode : manual
    MSM            : MSM
    
    
    
    PS C:\scripts> $hudson.WLANProfile.SSIDConfig
    
    SSID
    ----
    SSID
    
    
    PS C:\scripts> $hudson.WLANProfile.SSIDConfig.SSID
    
    hex                                                                                      name
    ---                                                                                      ----
    487564736F6E                                                                             Hudson
    
    
    PS C:\scripts>
     $hudson.WLANProfile.MSM.security.sharedKey.keyMaterial


    \_(ツ)_/


    • Edited by jrv Thursday, April 9, 2015 5:37 PM
    • Proposed as answer by jrv Thursday, April 9, 2015 5:40 PM
    • Marked as answer by bohlingj Thursday, April 9, 2015 7:23 PM
    Thursday, April 9, 2015 5:34 PM

All replies

  • So what's your specific question?


    -- Bill Stewart [Bill_Stewart]

    Thursday, April 9, 2015 2:32 PM
    Moderator
  • That command wont export to the csv. It just shows the document as empty.
    Thursday, April 9, 2015 2:40 PM
  • Try Out-File instead.

    You're not working with an object, so Export-Csv most likely won't work the way you're expecting.


    Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)

    Thursday, April 9, 2015 2:42 PM
  • Export-CSV requires input objects with properties.

    Capturing output of a command is a list of strings, not input objects with properties.

    Are you wanting to run 'netsh wlan show profile' for each profile name from 'netsh wlan show profiles'?


    -- Bill Stewart [Bill_Stewart]

    Thursday, April 9, 2015 2:43 PM
    Moderator
  • Thanks guys for the helpful knowledge. Yes Bill, I was wanting to do that.
    Thursday, April 9, 2015 3:08 PM
  • OK, so first, what does the output of the command 'netsh wlan show profiles' look like?

    -- Bill Stewart [Bill_Stewart]

    Thursday, April 9, 2015 5:16 PM
    Moderator
  • It looks like this.

    Profile " Profiles on interface Wi-Fi:  Group policy profiles (read only) ---------------------------------     <None>  User profiles -------------     All User Profile     : XXXX     All User Profile     : XXXX     All User Profile     : XXXX     All User Profile     : XXXX     All User Profile     : XXXX     All User Profile     : XXXX     All User Profile     : XXXX     All User Profile     : XXXX     All User Profile     : XXXX " is not found on the system.



    • Edited by bohlingj Thursday, April 9, 2015 5:26 PM
    Thursday, April 9, 2015 5:25 PM
  • All on one line like that?

    -- Bill Stewart [Bill_Stewart]

    Thursday, April 9, 2015 5:27 PM
    Moderator
  • Yeah, and no passwords or anything. When I run the command without the out-file it looks fine.

    $wifiname = netsh wlan show profiles
    netsh wlan show profiles name=$wifiname key=clear | out-file C:\users\XXXX\test.csv

    Thursday, April 9, 2015 5:32 PM
  • To get WiFi profiles as data use "export"

    netsh wlan export profile Hudson

    PS C:\scripts> netsh wlan export profile name="Hudson" folder="c:\test"
    
    Interface profile "Hudson" is saved in file "c:\test\Wi-Fi-Hudson.xml" successfully.
    
    PS C:\scripts> $hudson=[xml](Get-Content c:\test\Wi-Fi-Hudson.xml)
    PS C:\scripts> $hudson
    
    xml                                                                                      WLANProfile
    ---                                                                                      -----------
    version="1.0"                                                                            WLANProfile
    
    
    PS C:\scripts> $hudson.WLANProfile
    
    
    xmlns          : http://www.microsoft.com/networking/WLAN/profile/v1
    name           : Hudson
    SSIDConfig     : SSIDConfig
    connectionType : ESS
    connectionMode : manual
    MSM            : MSM
    
    
    
    PS C:\scripts> $hudson.WLANProfile.SSIDConfig
    
    SSID
    ----
    SSID
    
    
    PS C:\scripts> $hudson.WLANProfile.SSIDConfig.SSID
    
    hex                                                                                      name
    ---                                                                                      ----
    487564736F6E                                                                             Hudson
    
    
    PS C:\scripts>
     $hudson.WLANProfile.MSM.security.sharedKey.keyMaterial


    \_(ツ)_/


    • Edited by jrv Thursday, April 9, 2015 5:37 PM
    • Proposed as answer by jrv Thursday, April 9, 2015 5:40 PM
    • Marked as answer by bohlingj Thursday, April 9, 2015 7:23 PM
    Thursday, April 9, 2015 5:34 PM
  • Good reference Mike.

    bohlingj - you need to read and understand the wiki that Mike posted before continuing writing your script.


    -- Bill Stewart [Bill_Stewart]

    Thursday, April 9, 2015 5:34 PM
    Moderator
  • Don't use text use XML.  The output form netsh is not legacy. It is Unicode. NETSH is a modern app and is maintained in all versions of Windows since XP.  I suspect it will eventually migrate to PowerShell but is still used by many as a single independent utility.

    You cannot get passkeys from the rtext dump. You need to use export and read the XML.  You can also import the xml to define a connection in another system or use it as a backup.


    \_(ツ)_/


    • Edited by jrv Thursday, April 9, 2015 5:43 PM
    Thursday, April 9, 2015 5:42 PM
  • Thanks a lot guys I will check it out. Appreciate it.
    Thursday, April 9, 2015 5:44 PM