【发布时间】:2023-01-23 18:44:58
【问题描述】:
我正在尝试删除所有已保存的 wifi 配置文件,但不包括一个。
我有以下内容并且可以使用,但我不想删除/忘记其中一个 wifi SSID
$NetProfiles = (netsh.exe wlan show profiles) $网络档案 | netsh WLAN 删除配置文件*
有人有主意吗?
谢谢
【问题讨论】:
标签: powershell networkx
我正在尝试删除所有已保存的 wifi 配置文件,但不包括一个。
我有以下内容并且可以使用,但我不想删除/忘记其中一个 wifi SSID
$NetProfiles = (netsh.exe wlan show profiles) $网络档案 | netsh WLAN 删除配置文件*
有人有主意吗?
谢谢
【问题讨论】:
标签: powershell networkx
您有两种可能性,首先连接您的配置文件,然后删除所有其他配置文件保存,这将排除连接的配置文件:
$connectedProfile = (Get-NetworksConnection).Name
$profiles = Get-NetworksProfile
foreach ($profile in $profiles) {
if ($profile.Name -ne $connectedProfile) {
Remove-NetworksProfile -Name $profile.Name
}
}
或者,通过 exclude this 删除除您想要的以外的所有内容:
$profiles = Get-NetworksProfile
foreach ($profile in $profiles) {
if ($profile.Name -ne "myprofil") {
Remove-NetworksProfile -Name $profile.Name
}
}
您可以将“myprofile”更改为您要排除的名称,甚至是名称列表。
【讨论】:
Get-NetworksConnection / Remove-NetworksProfile / Get-NetworksProfile 不是默认的 cmdlet - 它们来自哪个模块?为什么不用Get-NetConnectionProfile?