Add rm_network.ps1

This commit is contained in:
Shockwave 2023-08-27 13:03:29 +08:00
parent 00bb9d2c24
commit 118a63813d
1 changed files with 30 additions and 0 deletions

View File

@ -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