我通过使用以下方式删除了一些IP地址:

Remove-NetIPAddress -InterfaceIndex $my.InterfaceIndex.

哪个工作正常。但是当我添加参数-Confirm
Remove-NetIPAddress -InterfaceIndex $my.InterfaceIndex -Confirm $false.

它失败如下:
Remove-NetIPAddress : No matching MSFT_NetIPAddress objects found by CIM query for instances of the ROOT/StandardCimv2/MSFT_NetIPAddress
class on the  CIM server: SELECT * FROM MSFT_NetIPAddress  WHERE ((IPAddress LIKE 'False')) AND ((InterfaceIndex = 15)). Verify query
parameters and retry.
At line:9 char:1
+ Remove-NetIPAddress -InterfaceIndex $my.InterfaceIndex -Confirm $false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (MSFT_NetIPAddress:String) [Remove-NetIPAddress], CimJobException
    + FullyQualifiedErrorId : CmdletizationQuery_NotFound,Remove-NetIPAddress

我应该如何使用-Confirm-PolicyStore参数?

最佳答案

因为-Confirm是Switch参数,所以您用冒号将false传递给它:

Remove-NetIPAddress -InterfaceIndex $my.InterfaceIndex -Confirm:$false

您只需声明自己就可以通过它。

08-07 21:21