【问题标题】:How to Change name of the NetConnectionProfile Using Set-NetConnectionProfile in PowerShell如何在 PowerShell 中使用 Set-NetConnectionProfile 更改 NetConnectionProfile 的名称
【发布时间】:2013-06-07 17:15:19
【问题描述】:

我尝试使用如何使用 Set-NetConnectionProfile 更改 NetConnectionProfile 的名称

$Profile=Get-NetConnectionProfile -InterfaceIndex 35
$Profile.Name = "Network1"            

错误是

"Name" is a ReadOnly property.
 At line:1 char:1
+ $Profile.Name = "Network1"
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) []
+ FullyQualifiedErrorId : ReadOnlyCIMProperty

如何更改名称的只读属性?帮帮我

【问题讨论】:

  • 你能解释一下吗?
  • 你应该避免在问题标题中放置标签。

标签: powershell powershell-2.0 powershell-3.0 powershell-ise


【解决方案1】:

Name 属性是只读的,因为您正在阅读这些名称。

$Profile=Get-NetConnectionProfile -InterfaceIndex 35

您正在尝试获取特定的配置文件索引名称。然后将其声明为“Network1”

了解如何通过属性名称使用 PowerShell 值绑定

http://blogs.technet.com/b/heyscriptingguy/archive/2013/03/25/learn-about-using-powershell-value-binding-by-property-name.aspx

了解和使用 PowerShell 配置文件

http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/04/understanding-and-using-powershell-profiles.aspx

【讨论】:

    【解决方案2】:

    @Yvette 是对的。我认为您无法更改此属性。该属性由系统决定。

    如果是域网络配置文件,它将是您的域名,例如。 example.com 和域名由域控制器决定。

    如果是 WiFi 网络配置文件,它将是 WiFi 设备的 SSID 名称,SSID 由您的 WiFi 设备决定。

    【讨论】:

      【解决方案3】:

      您可以通过直接注册版本来做到这一点。

      在钥匙下 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles

      您可以看到网络配置文件密钥(通过它的 uuid),并且可以更改适当的网络 ProfileName 值。

      【讨论】:

      • Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\"$UUID = "{01234ABC-...}"$VALUE = "Network1"(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\$UUID").ProfileNameSet-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\$UUID" -Name ProfileName -Value $VALUE
      【解决方案4】:

      可以使用 secpol 手动更改此属性。所以,我认为这不能改变。我只需要知道如何。 :-)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-11-22
        • 1970-01-01
        • 2018-05-27
        • 2014-08-23
        • 2011-08-02
        • 2021-01-07
        • 1970-01-01
        相关资源
        最近更新 更多