30 lines
1.1 KiB
PowerShell
30 lines
1.1 KiB
PowerShell
<#
|
|
使用随身 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 |