【问题标题】:Powershell - Remove all network profiles excluding onePowershell - 删除所有网络配置文件,不包括一个
【发布时间】:2023-01-23 18:44:58
【问题描述】:

我正在尝试删除所有已保存的 wifi 配置文件,但不包括一个。

我有以下内容并且可以使用,但我不想删除/忘记其中一个 wifi SSID

$NetProfiles = (netsh.exe wlan show profiles) $网络档案 | netsh WLAN 删除配置文件*

有人有主意吗?

谢谢

【问题讨论】:

    标签: powershell networkx


    【解决方案1】:

    您有两种可能性,首先连接您的配置文件,然后删除所有其他配置文件保存,这将排除连接的配置文件:

    $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
    猜你喜欢
    • 1970-01-01
    • 2022-01-04
    • 2017-05-08
    • 2014-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多