I need to know how many Vms has shared disks, wich are hostnames and clusters. Have an script for that or cmdlets ?????
Try something like this
foreach($vm in Get-VM){
$sharedSC= Get-ScsiController -VM $vm |
where {"Virtual","Physical" -contains $_.BusSharingMode}
if($sharedSC){
$sharedSCKey = $sharedSC | %{$_.Key}
Get-HardDisk -VM $vm |
where {$sharedSCKey -contains $_.ExtensionData.ControllerKey} |
Select @{N="VM";E={$_.Parent.Name}},Name,Filename
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
How do i import it to a excel or csv ?
Thanks
Bikash
The foreach doesn't place anything on the pipeline.
But you can fix this issue by running it as a codeblock.
$sharedSC= Get-ScsiController -VM $vm |
where {"Virtual","Physical" -contains $_.BusSharingMode}
if($sharedSC){
$sharedSCKey = $sharedSC | %{$_.Key}
Get-HardDisk -VM $vm |
where {$sharedSCKey -contains $_.ExtensionData.ControllerKey} |
Select @{N="VM";E={$_.Parent.Name}},Name,Filename
}
}} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LucD. I will try.