【发布时间】:2017-02-27 14:50:44
【问题描述】:
我正在尝试编写一个脚本来查找所有活动接口并将其网络类别设置为专用。理想情况下,我只会将当前设置为 Public 的接口设置为,但如果我尝试设置已设置的连接,我不认为这会导致任何问题。这是我对这项任务的谦虚尝试。
get-wmiobject win32_networkadapter -filter "netconnectionstatus = 2" | select netconnectionid, name InterfaceIndex, netconnectionstatus | ForEach-Object Set-NetConnectionProfile -interfaceindex {$_.InterfaceIndex} -NetworkCategory Private
这是我收到的错误。
ForEach-Object : Input name "Set-NetConnectionProfile" cannot be resolved to a method. At line:1 char:140 + ... ionstatus | ForEach-Object Set-NetConnectionProfile -interfaceindex { ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidArgument: (@{netconnection...ectionstatus=2}:PSObject) [ForEach-Object], PSArgumentException
+ FullyQualifiedErrorId : MethodNotFound,Microsoft.PowerShell.Commands.ForEachObjectCommand
我在 Windows 10 上运行 Powershell 5.0
【问题讨论】:
标签: windows powershell