Skip to main content

Implement Wifi Profile

Summary

This script is an Automate implementation of the Add-WifiProfile and Remove-WifiProfile agnostic scripts.

The script can both remove and add Wi-Fi profiles on the targeted machines. To initiate removal, the names of the desired Wi-Fi profiles should be supplied to the script parameter named Profiles_To_Remove. Conversely, for adding profiles, the respective profile names should be provided to the Profiles_To_Add parameter.

It is important to note that the addition of profiles can also be managed through the Client/Location level EDFs, as further elucidated in this document.

Note: Run the Get Wifi Profile script with the Set_Environment set to 1 to create the system properties and EDFs used by this script.

Image

Sample Run

  • The Wi-Fi Profile/SSID to remove from the computer should be provided within the Profiles_To_Remove parameter. Each SSID should be enclosed in double quotes and separated by a comma. If there is a comma (,) in the SSID, it should be replaced by a double semi-colon (;;).

    • Example 1: To remove a single Wifi Profile
      Image
    • Example 2: To remove multiple Wi-Fi Profiles
      Image
    • Example 3: If there is a comma in the Wi-Fi Profile Name, e.g., SSID with a , Comma or SSID , with multiple , Commas
      Image
  • The Wi-Fi Profile/SSID to be added from the computer should be provided within the Profiles_To_Add parameter. Each SSID should be enclosed in single quotes and separated by commas. Additionally, along with the names of the profiles, the Primary_Computerid parameter should be set to specify the computer ID from which the profile information is to be copied. While adding an SSID with a single quotation in the name itself, a backslash should be added before the quotation. The complete name should always be enclosed between the single quotations.
    For example:
    To add Bob's Wifi, it should be passed as 'Bob//\'s Wifi'.
    To add Bob's Wifi, HR's Wifi, and Wifi Network X, it should be passed as 'Bob//\'s Wifi', 'HR's Wifi', 'Wifi Network X'.

    • Example 1: To add a single Wifi Profile
      Image
    • Example 2: To add multiple Wifi Profiles
      Image

Dependencies

EPM - Windows Configuration - Script - Get Wifi Profile

Variables

NameDescription
ProjectNameAdd-WifiProfile, Remove-WifiProfile
WorkingDirectoryC:/ProgramData/_Automation/Script/Add-WifiProfile, C:/ProgramData/_Automation/Script/Remove-WifiProfile
PS1LogC:/ProgramData/_Automation/Script/Add-WifiProfile/Add-WifiProfile-log.txt, C:/ProgramData/_Automation/Script/Remove-WifiProfile/Remove-WifiProfile-log.txt
PS1ErrorLogC:/ProgramData/_Automation/Script/Add-WifiProfile/Add-WifiProfile-error.txt, C:/ProgramData/_Automation/Script/Remove-WifiProfile/Remove-WifiProfile-error.txt

User Parameters

NameExampleRequiredDescription
Profiles_To_Remove"SSID To Remove", "Suspicious Network"FalseSSID(s) of the unwanted/malicious Wi-Fi Profile(s) to remove from the end machine. Check the Sample Run section of the article for further details. If left blank, the script will just audit the Wi-Fi Profiles.
Profiles_To_Add'SSID To Add', 'Another'FalseSSID(s) of the Wi-Fi Profile(s) to add to the end machine. Check the Sample Run section of the article for further details. If left blank, the script will fallback to the location-level EDF Wifi Profiles To Add and then to the client-level EDF Wifi Profiles To Add.
Primary_Computerid294True (if Profiles_To_Add parameter is used)ID of the computer to fetch the information of the profiles to add.

System Properties

NameExampleRequiredDescription
Safe_Wifi_Networks"Safe Network", "Another Safe Network", "Safe Network With a ;; Comma"FalseStores the list of globally whitelisted/safe Wi-Fi profiles. The script will not accidentally remove the profile(s) if they are mentioned here. Each Name/SSID should be enclosed in double quotes and separated by a comma. If there is a comma (,) in the Wi-Fi Profile Name, it should be replaced by double semi-colon (;;). e.g., the way "Safe Network with a , comma" is saved in the screenshot.

Image

Client-Level EDFs

NameExampleRequiredDescription
Safe Wifi Networks"Client Level Safe Network", "Trusted Network", "Safest", "SSID with a ;; Comma"FalseIn addition to defining globally safe/whitelisted Wi-Fi profiles/networks, this EDF provides an option to define additional client-level safe/whitelisted Wi-Fi profiles as well. The profiles/SSIDs stored here will not be removed from the machine, even if someone passes that name to the Profiles_To_Remove parameter. The syntax for storing the Name(s) in the EDF is the same as the system property. Each Name should be enclosed in double quotes and separated by a comma. If there is a comma (,) in the Wi-Fi Profile Name, it should be replaced by double semi-colon (;;). e.g., the way "SSID with a , comma" is saved like this "SSID with a ;; comma"
Primary ComputerIDComputer Name (Computerid)True (if Client-level EDF Wifi Profiles To Add is set)To store the name and ID of the computer to fetch the information of the Wi-Fi profiles to add to the end machines of the client. It's a dropdown field with the Name (Computerid) of the computers of the client. Image
Wifi Profiles To Add'SSID1', 'SSID2', 'SSID3'FalseSSID or Name of the Wi-Fi Profile(s) to add to the end machines of the client. These Wi-Fi Profiles should be available on the computer selected in the Primary ComputerID EDF. Each SSID should be enclosed in single quotes and separated by commas. While adding an SSID with a single quotation in the name itself, a backslash should be added before the quotation. The complete name should always be enclosed between the single quotations. For example: To add Bob's Wifi in the EDF, it should be set as 'Bob//\'s Wifi'. To add Bob's Wifi, HR's Wifi, and Wifi Network X in the EDF, it should be set as 'Bob//\'s Wifi', 'HR's Wifi', 'Wifi Network X'. Image

Image

Location-Level EDFs

NameExampleRequiredDescription
Primary ComputerIDComputer Name (Computerid)True (if Location-level EDF Wifi Profiles To Add is set)To override the information stored in the client-level EDF Primary ComputerID. Image
Wifi Profiles To Add'SSID1', 'SSID2', 'SSID3'FalseTo override the information stored in the client-level EDF Wifi Profiles To Add. Image

Location-Level EDFs can be used to override the Client-Level EDFs. The syntax used to store data in the location-level EDF Wifi Profiles To Add is the same as that of the client-level EDF Wifi Profiles To Add.

Image

Computer-Level EDFs

NameExampleRequiredDescription
Exclude From Wifi Profile AdditionCheck BoxFalseThis EDF has no effect on the script but can be used to exclude the computer from the CWM - Automate - Internal Monitor - Add - Wifi Profiles monitor set detections.

Image

Output

  • Script Log
  • Dataview