Hi,
I require two scripts to collect vm disk info,
1. Script to collect vm Disk mode info
Expected Output:
VM Name | ESX name | Cluster Name | vmdk name | Device Label | disksizeInGB | diskmode
Disk mode --> Just need the info like persistent or independent_persistent
2. Script to collect RDM info from Vm's
Expected output:
VM Name | ESX name | Cluster Name | DeviceName | FileName | Compatiblity Mode | Size
The first script
Get-VM | %{ $vm = $_ $vm | Get-HardDisk | %{ $_ | select @{N="VM";E={$vm.Name}}, @{N="ESX";E={$vm.Host}}, @{N="Cluster";E={(Get-VMHost $vm.Host | Get-Cluster).Name}}, @{N="VMDK";E={$_.Filename}}, @{N="Device Label";E={$_.Name}}, @{N="disksizeInGB";E={"{0:N1}" -f ($_.CapacityKB/1MB)}}, @{N="Diskmode";E={$_.Persistence}} } } | ft -AutoSize -Force
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The first script
Get-VM | %{ $vm = $_ $vm | Get-HardDisk | %{ $_ | select @{N="VM";E={$vm.Name}}, @{N="ESX";E={$vm.Host}}, @{N="Cluster";E={(Get-VMHost $vm.Host | Get-Cluster).Name}}, @{N="VMDK";E={$_.Filename}}, @{N="Device Label";E={$_.Name}}, @{N="disksizeInGB";E={"{0:N1}" -f ($_.CapacityKB/1MB)}}, @{N="Diskmode";E={$_.Persistence}} } } | ft -AutoSize -Force
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The 2nd script.
Get-VM | %{ $vm = $_ $vm | Get-HardDisk | where {"RawPhysical","RawVirtual" -contains $_.DiskType} | %{ $_ | select @{N="VM";E={$vm.Name}}, @{N="ESX";E={$vm.Host}}, @{N="Cluster";E={(Get-VMHost $vm.Host | Get-Cluster).Name}}, @{N="DeviceName";E={$_.DeviceName}}, @{N="CanonicalName";E={$_.ScsiCanonicalName}}, @{N="Filename";E={$_.Filename}}, @{N="Compatibility Mode";E={$_.DiskType}}, @{N="disksizeInGB";E={"{0:N1}" -f ($_.CapacityKB/1MB)}} } } | ft -AutoSize -Force
Since I wasn't sure if you wanted the Device or the Canonical name I put both in.
You can remove the line of the one you don't want.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Just awesome. First script works very good. Will be running second script soon.
Thanks a lot Luc.
Luc,
Need a small change in 1st script. I need to run this script on some specific cluster's alone. Can you please alter this script so that it prompts for the cluster name and then it runs on the VM's on that particular cluster alone.
Here you go
$cluster = Read-Host -Prompt "Enter the cluster name (<Enter> will report on all clusters)" Get-Cluster $cluster | Get-VM | %{ $vm = $_ $vm | Get-HardDisk | %{ $_ | select @{N="VM";E={$vm.Name}}, @{N="ESX";E={$vm.Host}}, @{N="Cluster";E={(Get-VMHost $vm.Host | Get-Cluster).Name}}, @{N="VMDK";E={$_.Filename}}, @{N="Device Label";E={$_.Name}}, @{N="disksizeInGB";E={"{0:N1}" -f ($_.CapacityKB/1MB)}}, @{N="Diskmode";E={$_.Persistence}} } } | ft -AutoSize -Force
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Works perfect. Thank you so much.
Hello
Maybe it is to much what I want, but It would be great if you do this for me.
Is it possible to merge your script with the script of "ibeerens" http://communities.vmware.com/docs/DOC-7430
After "Virtual Machine information"
I tried it by myself, but I have no idea to get it in colums like all the other informations.
If it to much than maybe you can tell how get the information in a txt-file?
This would really make my day!!
Thanks in advance!
Erich