Add rm_network.ps1
This commit is contained in:
parent
00bb9d2c24
commit
118a63813d
|
@ -0,0 +1,30 @@
|
||||||
|
<#
|
||||||
|
使用随身 wifi 多次后,会出现很多网络,该脚本可以删除注册表中的网络
|
||||||
|
#>
|
||||||
|
function ResetNetworks() {
|
||||||
|
$networkList = 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles'
|
||||||
|
$unmanagedNetworkList = 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\Unmanaged'
|
||||||
|
$values = Get-ChildItem($networkList)
|
||||||
|
foreach ($item in $values) {
|
||||||
|
$itemProperties = Get-ItemProperty -Path $item.PSPath
|
||||||
|
if ($itemProperties.Description -eq "网络") {
|
||||||
|
Remove-Item $item.PSPath
|
||||||
|
$tmp = "Deleting profile: {0}" -f $itemProperties.ProfileName
|
||||||
|
Write-Host $tmp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# echo $values
|
||||||
|
|
||||||
|
Write-Host "Profiles clean finished, now begin to clear unmanaged items"
|
||||||
|
$values = Get-ChildItem $unmanagedNetworkList
|
||||||
|
foreach ($item in $values) {
|
||||||
|
$itemProperties = Get-ItemProperty -Path $item.PSPath
|
||||||
|
if ($itemProperties.Description.StartsWith("网络")) {
|
||||||
|
Remove-Item $item.PSPath
|
||||||
|
$tmp = "Deleting unmanaged: {0}" -f $itemProperties.FirstNetwork
|
||||||
|
Write-Host $tmp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ResetNetworks
|
Loading…
Reference in New Issue