Hi guy's .
I have a problem with my script.
I want export details from my vcenter and I had a problem with export Tag's.
My script :
Get-VM | `
ForEach-Object {
$Tag = $VM | Get-TagAssignment
$VM = $_
$VMview = $VM | Get-View
$VMResourceConfiguration = $VM | Get-VMResourceConfiguration
$VMHardDisks = $VM | Get-HardDisk
$HardDisksSizesGB = @()
$Temp = $VMHardDisks | ForEach-Object { $HardDisksSizesGB += [Math]::Round($_.CapacityKB/1MB) }
$VmdkSizeGB = ""
$Temp = $HardDisksSizesGB | ForEach-Object { $VmdkSizeGB += "$_+" }
$VmdkSizeGB = $VmdkSizeGB.TrimEnd("+")
$TotalHardDisksSizeGB = 0
$Temp = $HardDisksSizesGB | ForEach-Object { $TotalHardDisksSizeGB += $_ }
$Snapshots = $VM | Get-Snapshot
$Report = "" | Select-Object VMname,ESXname,Tag,MemoryGB,vCPUcount,vNICcount,IPaddresses,VmdkSizeGB,TotalVmdkSizeGB,DatastoreName,ToolsVersion,ToolsUpdate,SnapshotCount,GuestOS
$Report.VMName = $VM.name
$Report.ESXname = $VM.Host
$Report.Tag = $_.Tag
$Report.MemoryGB = $VM.MemoryMB/1024
$Report.vCPUcount = $VM.NumCpu
$Report.vNICcount = $VM.Guest.Nics.Count
$Report.IPaddresses = $VM.Guest.IPAddress
$Report.VmdkSizeGB = $VmdkSizeGB
$Report.TotalVmdkSizeGB = $TotalHardDisksSizeGB
$Report.DatastoreName = $VMview.Config.DatastoreUrl
$Report.ToolsVersion = $VMview.Config.Tools.ToolsVersion
$Report.ToolsUpdate = $VMview.Guest.ToolsStatus
$Report.SnapshotCount = (@($VM | Get-Snapshot)).Count
$Report.GuestOS = $VM.Guest.OSFullName
Write-Output $Report | export-csv –append –path c:\temp\AlexTag8.csv
}
I export all without tags and I don't understand why..
Thanks ALL.
Alex.