Reputation: 41
I am removing some IP addresses by using:
Remove-NetIPAddress -InterfaceIndex $my.InterfaceIndex.
Which works OK. But when I add the parameter -Confirm
Remove-NetIPAddress -InterfaceIndex $my.InterfaceIndex -Confirm $false.
It fails as follows:
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
How should I use the -Confirm
, and -PolicyStore
parameters?
Upvotes: 3
Views: 3972
Reputation: 23385
Because -Confirm
is a Switch parameter you pass false to it with a colon:
Remove-NetIPAddress -InterfaceIndex $my.InterfaceIndex -Confirm:$false
You pass true to it by just declaring it on its own.
Upvotes: 4