Hi,
I'm trying to collect some basic info on VM's that's needed before a planned upgrade from VC5.5 to VC6.0
I have the majority of the info that I need (for now) but am struggling to get VMFS Version and Blocksize info for each VM.
For each VM, I would like to report the VMFS Version and Blocksize.
If a VM has multiple Datastores, I want to report report unique Version and Blocksize info (I thought I could do this using Group-Object)
Below is the code that I have come up with so far (the VMFS piece is not working)
For testing on a single VM, I've #'ed out the Cluster info in the first few lines
#$cluster = Get-Cluster (Read-Host "Enter Target Cluster name: ")
$outputfile = "C:\Temp\Report-" + (Get-Date -Format yyyy-MMM-dd-HHmm) + ".csv"
$ClusterReport=@()
$test = Get-VM yourVMname
foreach($item in $test){
#foreach($item in (Get-VM -Location $cluster)){
$GeneralProp=[ordered]@{
'ComputerName'=$item.Name;
'PowerState'=$item.PowerState;
'VMware Tools'=$item.Guest.ToolsVersion;
'Num CPU'=$item.NumCpu;
'Memory GB'=$item.MemoryGB;
'Cluster'=$item.VMHost.Parent.Name;
'Host'=$item.VMHost;
'Host Build #'=$item.VMHost.Build;
'ResourcePool'=$item.ResourcePool;
}
$view = $item | Get-View
$GeneralProp.Add("Guest O/S", $view.Guest.GuestFullName)
$GeneralProp.Add("Guest O/S State", $view.Guest.GuestState)
$GeneralProp.Add("Tools Status", $view.Guest.ToolsStatus)
$GeneralProp.Add("H/W Ver", $view.Config.Version.split("-")[1])
$GeneralProp.Add("Notes", $view.config.Annotation)
$GeneralProp.Add("F/T", $view.Runtime.FaultToleranceState)
$GeneralProp.Add("Snapshot", $view.snapshot)
$BlueFolder = Get-View $view.Parent
$BF_Path = $view.Name
do {
$parent = $BlueFolder
if($parent.Name -ne "vm"){$BF_Path = $parent.Name + "\" + $BF_Path}
$BlueFolder = Get-View $BlueFolder.Parent
} while ($BlueFolder.Parent -ne $null)
$generalProp.Add("Blue Folder",$BF_Path)
$DS_View = $item | Get-Datastore | Get-View | select @{N="VMFS Version";E={$_.Info.Vmfs.MajorVersion}},@{N="VMFS Block Size";E={$_.Info.Vmfs.BlockSizeMB}}
$VMFS_Version = $DS_View.Info.Vmfs.MajorVersion | Group-Object -Property name
$VMFS_BlockSize = $DS_View.Info.Vmfs.BlockSizeMB | Group-Object -Property name
$GeneralProp.Add("VMFS Version",$VMFS_Version)
$GeneralProp.Add("VMFS Block Size",$VMFS_BlockSize)
$nic = 1
$item | Get-VirtualPortGroup | foreach {
$GeneralProp.Add("NIC$($nic) vSwitch",$_.VirtualSwitch)
$GeneralProp.Add("NIC$($nic) PortGroup",$_.Name)
$GeneralProp.Add("NIC$($nic) VLAN ID",$_.VlanID)
$GeneralProp.Add("NIC$($nic) IP", $item.Guest.IPAddress[$nic-1])
$nic++
}
$ClusterReport += New-Object -TypeName psobject -Property $GeneralProp
}
# Create the .csv file
$ClusterReport |
Sort-Object -Property {($_ | Get-Member -MemberType NoteProperty).Count } -Descending |
Export-Csv $outputfile -NoTypeInformation