我喜欢使用 PowerShell 查找驻留在 iSCSI 磁盘上的所有磁盘分区。
要查找所有 iSCSI 磁盘对象 ID,我们可以使用:
Get-Disk | Where BusType -ieq iscsi | Select -prop ObjectId
使用in
运算符,这应该返回所有分区:
Get-Partition | Where DiskId in (Get-Disk | Where BusType -ieq iscsi | Select -prop ObjectId)
不幸的是,这个命令返回一个典型的 PowerShell 错误:
Where-Object : A positional parameter cannot be found that accepts argument 'System.Object[]'.
At line:1 char:17
+ Get-Partition | Where DiskId in (Get-Disk | Where BusType -ieq iscsi | Select -p ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Where-Object], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.WhereObjectCommand
如何in
正确使用运算符?