PoshCode Logo PowerShell Code Repository

Export-WLANSettings.ps1 by Jan Egil Ring 23 months ago
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1700"></script>download | new post

Using netsh.exe to loop through each WLAN on the system and export the settings to the user-provided output-file.

  1.  # ==============================================================================================
  2.  #
  3.  #
  4.  # NAME: Export-WLANSettings.ps1
  5.  #
  6.  # AUTHOR: Jan Egil Ring
  7.  #
  8.  # DATE  : 14.03.2010
  9.  #
  10.  # COMMENT: Using netsh.exe to loop through each WLAN on the system and export the settings to the user-provided output-file.
  11.  #          Must be run with Administrator-privileges for the Key Content (security key) to be exported.
  12.  #
  13.  #
  14.  # ==============================================================================================
  15.  
  16. Write-Warning "Must be run with Administrator-privileges for Key Content to be exported"
  17. $filepath = Read-Host "Provide path to output-file. E.g. C:\temp\wlan.txt"
  18.  
  19. $wlans = netsh wlan show profiles | Select-String -Pattern "All User Profile" | Foreach-Object {$_.ToString()}
  20. $exportdata = $wlans | Foreach-Object {$_.Replace("    All User Profile     : ",$null)}
  21. $exportdata | ForEach-Object {netsh wlan show profiles name="$_" key=clear} | Out-File $filepath

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me