Help with PowerShell Script to Delete Known Networks

0
3
Asked By TechWhiz42 On

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

Answered By ErrorHunter77 On

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.

Answered By NetworkGuru92 On

Have you considered using Group Policy or Intune to manage Wi-Fi settings? It might be a more straightforward approach.

Answered By KeyboardNinja88 On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.