文件:https://drive.google.com/file/d/10GAlcA9PI-mFHUmACvC5CPbzjl3QLrwJ/view?usp=sharing
$data = import-csv .\vDisk.csv |where 'raw lun id' -NotLike ''|Group-Object -Property VM -ashashtable
我从 rvtools 中提取了 vdisk 并尝试按 VM 名称对共享 RDM 进行分组,代码的输出是:
Name Value
---- -----
MGTMKS1112M {@{VM=MGTMKS1112M; Powerstate=poweredOff; Template=False; Disk=Hard disk 7; Capacity MB=150; Raw=True; Disk Mode=independent_persistent; Thin=; Eagerly Scrub=; Split=; Wri...
PRDSKM1111M {@{VM=PRDSKM1111M; Powerstate=poweredOff; Template=False; Disk=Hard disk 5; Capacity MB=1,024; Raw=True; Disk Mode=independent_persistent; Thin=; Eagerly Scrub=; Split=; W...
MGTMKS1111M {@{VM=MGTMKS1111M; Powerstate=poweredOff; Template=False; Disk=Hard disk 11; Capacity MB=150; Raw=True; Disk Mode=independent_persistent; Thin=; Eagerly Scrub=; Split=; Wr...
PRDSKM1112M {@{VM=PRDSKM1112M; Powerstate=poweredOff; Template=False; Disk=Hard disk 5; Capacity MB=1,024; Raw=True; Disk Mode=independent_persistent; Thin=; Eagerly Scrub=; Split=; W...
我想要类似下面的 ashashtable 或分组对象的输出。因为两个节点共享相同的原始 lun id。如果这种方法行不通。任何替代方法?请指教。
Name Value
---- -----
MGTMKS1112M,MGTMKS1111M {@{VM=MGTMKS1112M; Powerstate=poweredOff; Template=False; Disk=Hard disk 7; Capacity MB=150; Raw=True; Disk Mode=independent_persistent; Thin=; Eagerly Scrub=; Split=; Wri...
PRDSKM1112M,PRDSKM1112M {@{VM=PRDSKM1112M; Powerstate=poweredOff; Template=False; Disk=Hard disk 5; Capacity MB=1,024; Raw=True; Disk Mode=independent_persistent; Thin=; Eagerly Scrub=; Split=; W...
答案 0 :(得分:1)
您可以向 Group-Object 提供自定义属性,以便在其中进行分组
$data = import-csv .\vDisk.csv |where 'raw lun id' -NotLike ''
$data | Group-Object -Property { $sub = $_.vm.substring(0,9); ($data.vm -match $sub | Select-Object -Unique | Sort-Object) -join ", "} -ashashtable
输出类似这样的东西
Name Value
---- -----
MGTMKS1111M, MGTMKS1112M {@{VM=MGTMKS1111M; Powerstate=poweredOff; Template=False; Disk=Hard disk 11; Capacity MB=150; Raw=True; Disk Mode=independent_persistent; Thin=; Eagerly Scrub=; Split=; Write Through=; Level=normal; Shares=1,000; Reservation=0; L...
PRDSKM1111M, PRDSKM1112M {@{VM=PRDSKM1111M; Powerstate=poweredOff; Template=False; Disk=Hard disk 5; Capacity MB=1,024; Raw=True; Disk Mode=independent_persistent; Thin=; Eagerly Scrub=; Split=; Write Through=; Level=normal; Shares=1,000; Reservation=0; ...