Help with PowerShell Script to Delete Known Networks

June 9, 2025 3 answers
Asked by TechWhiz42
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!

Answers

KeyboardNinja88
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!

ScriptSavvy101: Can you give me an example of how to use plain `"`? I'm not sure what you mean.

Reply to this answer
NetworkGuru92
Have you considered using Group Policy or Intune to manage Wi-Fi settings? It might be a more straightforward approach.
Reply to this answer
ErrorHunter77
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?

TechWhiz42: 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.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions