Hey everyone! I found this [link](https://joymalya.com/how-to-block-managed-device-from-connecting-to-specific-wlan-ssids-with-intune/#comments) while searching for a PowerShell script that can help me delete certain known networks and block access to them on managed devices. I can run the individual `netsh wlan` commands successfully in PowerShell, but when I try to run the full script below, I keep getting an error saying that one or more parameters for the command are incorrect or missing. Here's the script I'm working with:
$PackageName = "Block-Wi-Fi-SSID"
$Path_local = "C:ProgramDataMicrosoftIntuneManagementExtensionLogs"
Start-Transcript -Path "$Path_local$PackageName-install.log" -Force
netsh wlan delete profile name=c9Company Guestc9 i=*
netsh wlan delete profile name=c9Company WiFic9 i=*
netsh wlan add filter permission=block ssid=c9Company Guestc9 networktype=infrastructure
Stop-Transcript
Any insights would be greatly appreciated!
3 Answers
Can you show us the actual error message? You're running multiple commands, so it's hard to tell which one is causing issues. If you save the script as a `.ps1` file and run it directly like this: `powershell -file xxx.ps1`, does it still throw the same error?
Have you considered using Group Policy or Intune to manage Wi-Fi settings? It might be a more straightforward approach.
It looks like you might have copy-pasted some fancy quotes in your script. Make sure you're using plain `"` for the quotes instead of those curly ones. That could definitely be causing the issue!
Can you give me an example of how to use plain `"`? I'm not sure what you mean.
Here's the error I got:
One or more parameters for the command are not correct or missing.
Usage: delete profile [name=]<string> [[interface=]<string>]
...
The profile name is required. It seems none of the commands are running correctly.