Advertisement
nerdemma

PowerShell Wireless Connection

Jul 6th, 2023
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 1.48 KB | Source Code | 0 0
  1. #PS Wlan Script Connection
  2. #Created by Emmanuel.D.Breyaue
  3. #Credits by
  4. #nerdemma.mastodon.social
  5. #links.rebel.ar/nerdemma
  6.  
  7.  
  8. #set folder to the xml profile conection file.
  9.  
  10. $CURRENT_DIR=(pwd).path
  11.  
  12. $PATH = $CURRENT_DIR+"\Profiles\"
  13. $NAME = Read-Host -Prompt "NAME OF ACCESS POINT (SSID)"
  14. $FILE=$NAME
  15. $AUTHENTICATION = 'WPA2PSK'
  16. $ENCRYPTION = 'AES'
  17. $PASSWORD = Read-Host -Prompt "PASSWORD"
  18.  
  19.  
  20. #save the xml profile connection file
  21.  
  22. $NEWPROFILE = @'
  23. <?xml version="1.0"?>
  24. <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
  25.     <name>{0}</name>
  26.     <SSIDConfig>
  27.         <SSID>
  28.             <name>{0}</name>
  29.         </SSID>
  30.     </SSIDConfig>
  31.     <connectionType>ESS</connectionType>
  32.     <connectionMode>auto</connectionMode>
  33.     <MSM>
  34.         <security>
  35.             <authEncryption>
  36.                 <authentication>{1}</authentication>
  37.                 <encryption>{2}</encryption>
  38.                 <useOneX>false</useOneX>
  39.             </authEncryption>
  40.             <sharedKey>
  41.                 <keyType>passPhrase</keyType>
  42.                 <protected>false</protected>
  43.                 <keyMaterial>{3}</keyMaterial>
  44.             </sharedKey>
  45.         </security>
  46.     </MSM>
  47.     <MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
  48.         <enableRandomization>false</enableRandomization>
  49.     </MacRandomization>
  50. </WLANProfile>
  51. '@ -f $NAME, $AUTHENTICATION, $ENCRYPTION, $PASSWORD
  52. $FILE=$FILE+'.xml'
  53.  
  54. $NEWPROFILE | Out-File $PATH$FILE
  55.  
  56.  
  57. #conect $name y/n
  58. #connecting to the network
  59. netsh wlan add profile filename=$PATH$FILE
  60. netsh wlan connect name=$NAME ssid=$NAME
  61. netsh wlan show interfaces
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement