Skip to content

Instantly share code, notes, and snippets.

@iamgabeortiz
Created August 14, 2014 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamgabeortiz/f84e74d7753dd1f251a4 to your computer and use it in GitHub Desktop.
Save iamgabeortiz/f84e74d7753dd1f251a4 to your computer and use it in GitHub Desktop.
Removing Insecure Wireless Connections with PowerShell
#http://www.leeholmes.com/blog/2013/06/06/removing-insecure-wireless-connections-with-powershell/
function Get-WlanProfile
{
netsh wlan show all |
sls "^[\s]+Name\s+:" -Context 16 |
% {
$conn = [Ordered] @{}
$_.Line, $_.Context.PostContext[1], $_.Context.PostContext[15] | % {
$label,$value = $_ -split ‘:’
$conn[$label.Trim()] = $value.Trim()
}
$result = [PSCustomObject] $conn
if($result.Name -and $result.Authentication) { $result }
}
}
function Get-UnsecureWlanProfile
{
Get-WlanProfile | ? {
($_.Authentication -eq ‘Open’) -and
($_."Connection mode" -match "automatically")
}
}
function Remove-WlanProfile
{
param(
[Parameter(ValueFromPipelineByPropertyName)]
$Name
)
netsh wlan delete profile name="$Name"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment