如果我运行Get-NetIPInterface -ifIndex 29 -IncludeAllCompartments
,我得到一个接口。
只有2个隔间我通过@(Get-NetCompartment).Count
。 分区ID是1和2.此信息也由Get-NetCompartment
打印。
但是,如果我运行Get-NetIPInterface -CompartmetId 2我得到这个错误:
PS C:\Users\Administrator> Get-NetIPInterface -ifIndex 29 -CompartmentId 1 Get-NetIPInterface : No matching MSFT_NetIPInterface objects found by CIM query for instances of the ROOT/StandardCimv2/MSFT_NetIPInterface class on the CIM server: SELECT * FROM MSFT_NetIPInterface WHERE ((InterfaceIndex = 29)) AND ((CompartmentId = 1)). Verify query parameters and retry. At line:1 char:1 + Get-NetIPInterface -ifIndex 29 -CompartmentId 1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (MSFT_NetIPInterface:String) [Get-NetIPInterface], CimJobException + FullyQualifiedErrorId : CmdletizationQuery_NotFound,Get-NetIPInterface
或这个
PS C:\Users\Administrator> Get-NetIPInterface -ifIndex 29 -CompartmentId 2 Get-NetIPInterface : No matching MSFT_NetIPInterface objects found by CIM query for instances of the ROOT/StandardCimv2/MSFT_NetIPInterface class on the CIM server: SELECT * FROM MSFT_NetIPInterface WHERE ((InterfaceIndex = 29)) AND ((CompartmentId = 2)). Verify query parameters and retry. At line:1 char:1 + Get-NetIPInterface -ifIndex 29 -CompartmentId 2 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (MSFT_NetIPInterface:String) [Get-NetIPInterface], CimJobException + FullyQualifiedErrorId : CmdletizationQuery_NotFound,Get-NetIPInterface PS C:\Users\Administrator>
为什么我得到这个错误?
如果界面不在隔间1而不在隔间2中,那么它在哪里?
更多信息:
PS C:\Users\Administrator> Get-NetIPInterface -ifIndex 29 -IncludeAllCompartments ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore ------- -------------- ------------- ------------ --------------- ---- --------------- ----------- 29 NIC_INTERN_CONTOSO IPv4 1500 5 Disabled Connected ActiveStore PS C:\Users\Administrator> Get-NetCompartment CompartmentId : 1 CompartmentDescription : Default Compartment CompartmentGuid : !SOME NUMBERS! CompartmentId : 2 CompartmentDescription : COMPARTMENT2 CompartmentGuid : !SOME NUMBERS"
你应该能够使用这样的东西来找出它是在什么样的CompartmentId:
Get-NetIPInterface -ifIndex 29 -IncludeAllCompartments | ForEach-Object { "$($_.InterfaceAlias) - $($_.CompartmentId)" }
用它来检查它是否在其中一个隔间中。