Background: The NETSH command allows one to manage wireless profiles but does anyone know if it allows one to CREATE wireless profiles?
I can create a wireless profile manually through the GUI on a reference computer, and then export it to an .XML file, which I can then use with the NETSH command to configure that network profile on any other system I want, but that's not what I want to do.
Problem: In Windows 7, I want to use the command line in place of the GUI to CREATE a wireless profile. How do I do that?
Don't know where I got this from (and please forgive me for providing VB instead of PowerShell) but maybe this can help you:
strComputer = "." Set objWMIService2 = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colAdapters = objWMIService2.ExecQuery _ ("Select * from Win32_NetworkAdapter")
wirelessfound=False
For Each objAdapter in colAdapters 'msgbox wscript.echo objAdapter.Name & " " & objAdapter.Description & " " & objAdapter.NetConnectionID if (instr(lcase(objAdapter.Name & objAdapter.Description & objAdapter.NetConnectionID), "wireless") or _ instr(lcase(objAdapter.Name & objAdapter.Description & objAdapter.NetConnectionID), "wlan") or _ instr(lcase(objAdapter.Name & objAdapter.Description & objAdapter.NetConnectionID), "weth0") or _ instr(lcase(objAdapter.Name & objAdapter.Description & objAdapter.NetConnectionID), "802.11")) then
debugecho "Wireless Found: " & objAdapter.Name wirelessfound = true exit for end if Next
If (wirelessfound) Then If GetOSVersion = "6.1.7600" Then wshshell.Run "cmd /c REG.EXE ADD ""HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""C:\Temp\wireless\zwlancfg.exe"" /t REG_SZ /d ""VISTASP2"" /f", 0, 1 wshshell.Run "cmd /c REG.EXE ADD ""HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""C:\Temp\wireless\zwlancfg.exe"" /t REG_SZ /d ""VISTASP2"" /f", 0, 1 WScript.Sleep 2000 End If wshshell.Run "cmd /c path\to\zwlancfg.exe /ssid:""SSID"" /ct:""ESS"" /mode:""auto"" /auth:""WPA2PSK"" /encrypt:""TKIP"" /keytype:""passPhrase"" /key:"""&encryptedkey&"""" End If
Function GetOSVersion Dim System for each System in GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem") GetOSVersion = System.Version Next End Function