This worked until recently and I do not believe anything has changed. Now nothing is returning for the UUID. Thanks.
$report = @()
foreach($vm in Get-VM){
$guest = Get-VMGuest -VM $vm
$row = "" | Select UUID,VMName
$row.UUID = $vm.ExtensionData.config.uuid
$row.VMName = $vm.Name
$report += $row
}
$report | Export-Csv "$filename1" -NoTypeInformation -UseCulture
Disconnect-VIServer -Confirm:$False
That PowerCLI version quite old, you could consider upgrading to 5.0.1
Since you apparently use the $guest variable later on in the script, the bold line has to stay.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Still works for me.
Which versions (vSPhere & PowerCLI) are you using ?
Btw why is the Get-VMGuest in there, that is not needed.
$report = @() foreach($vm in Get-VM ){ $row = "" | Select UUID,VMName $row.UUID = $vm.ExtensionData.config.uuid
$row.VMName = $vm.Name
$report += $row } $report
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm not sure if I follow everything in your code exactly, but you can access the extensiondata directly from your get-vm object to make it much simpler.
get-vm | foreach {$_.name,$_.extensiondata.config.uuid}
Looks like LUCD beat me to the punch.
CLI is 4.0.1.2164
vSphere is 4.1 and 5.0
Here is my full function and I'm actually trying to pull a lot of data. I have the blanks in there because I pull them in other scripts and then parse it together using Perl. I don't know why it is in there, but I can drop that bold line?
function vCell01Data {
$filename1 = 'C:\MyDocs\work\Virtualization\VMWare\VMware_Healthcheck\Notes_Fields\TCOMDB_Data\vcell01_consolidated_tcomdb1.csv'
write-host ("Working on VM data for $VIServer....")
$VIServer = "rtpvcell70"
connect-viserver -server $VIServer -user $User -password $Password
$report = @()
foreach($vm in Get-VM){
$guest = Get-VMGuest -VM $vm
$row = "" | Select UUID,VMName,Notes,vCenter,IPAddr,Owner1,Owner2,VP,OSFullName,Product,Resourcepool,TotalMemory,TotalCPU,DisksGB,ToolsStatus,VMState,Datastore,NumSnaps,SizeSnaps,One,Two,Three,DOB,EXP,Six,Seven,Eight,Nine,Ten,Eleven,Twelve,Thirteen
$row.UUID = $vm.ExtensionData.config.uuid
$row.VMName = $vm.Name
#$row.Notes = $VM.Description
$notesfield = $VM.Description
$row.Notes = ($notesfield -replace ",",";")
$row.vCenter = $VIServer
$row.IPAddr = $guest.IPAddress[0]
$row.Owner1 = ""
$row.Owner2 = ""
$row.Product = ""
$OS = $vm.Guest.OSFullName
$row.OSFullName = ($OS -replace ",","")
$repo = (Get-ResourcePool -VM $vm).Name
$row.Resourcepool = ($repo -replace ",","")
$row.TotalMemory = $vm.memorymb
$row.TotalCPU = $vm.numcpu
$row.DisksGB = [Math]::Round((($VM.HardDisks | Measure-Object -Property CapacityKB -Sum).Sum * 1KB / 1GB),2)
$row.ToolsStatus = $vm.Extensiondata.Guest.toolsstatus
$row.VMState = $vm.powerState
$dstore = [string]::Join(',',(Get-Datastore -VM $vm | %{$_.Name}))
$row.Datastore = ($dstore -replace ",",";")
$row.NumSnaps = ""
$row.SizeSnaps = ""
$row.One = ""
$row.Two = ""
$row.Three = ""
$row.DOB = ""
$row.EXP = ""
$row.Six = ""
$row.Seven = ""
$row.Eight = ""
# Nine is the utilization metric:
$row.Nine = ""
$row.Ten = ""
$row.Eleven = ""
$row.Twelve = ""
$row.Thirteen = ""
#$row.Fourteen = ""
$report += $row
}
$report | Export-Csv "$filename1" -NoTypeInformation -UseCulture
Disconnect-VIServer -Confirm:$False
}
That PowerCLI version quite old, you could consider upgrading to 5.0.1
Since you apparently use the $guest variable later on in the script, the bold line has to stay.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That did it....thanks guys!!!
Looks like LUCD beat me to the punch.
I agree. LUCD has written a PowerCLI script to browse the communities, grep the questions and answer them automatically on the questions :smileysilly:
JFF :smileygrin:, he is the Lord Of The PCLI