Created
August 14, 2014 20:54
-
-
Save iamgabeortiz/f84e74d7753dd1f251a4 to your computer and use it in GitHub Desktop.
Removing Insecure Wireless Connections with PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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