VMware {code} Community
swamynaveen
Enthusiast
Enthusiast

How to Fetch Vm folder and Associated tag by using Get-VIEvent cmdlet

Hi All, I am trying to use below script to fetch the vm builds report for last 24hrs.However, the script doesn't fetching VM's folder & associated TAG details in the report. Any suggestions and help in fetching VM's folder & associated tag details by using Get-VIEvent cmdlet. Pls advise.

 

$Report1 = Foreach ($VC in $global:DefaultVIServers}) {
Get-VIEvent -MaxSamples ([int]::MaxValue) -Start (Get-Date).AddDays(-1) |where {$_.Gettype().Name-eq "VmCreatedEvent" -or $_.Gettype().Name-eq "VmBeingClonedEvent" -or $_.Gettype().Name-eq "VmBeingDeployedEvent" -or $_.Gettype().Name-eq "VmRegisteredEvent"}| Select CreatedTime,UserName,@{ Name="VM"; Expression={$_.Vm.Name}},@{ Name="Folder"; Expression={(Get-VM -Name $_).Folder}},@{ Name="VeeamTag"; Expression={(Get-TagAssignment -Entity $_).Tag.Name -join '|'}}, @{ Name="CPU"; Expression={(Get-VM -Name $_.Vm.Name).NumCPU}},@{ Name="Memory"; Expression={[math]::Round(((Get-VM -Name $_.Vm.Name).MemoryMB)/1024)}},@{ Name="Provisionedspace"; Expression={(Get-VM -Name $_.Vm.Name).ProvisionedSpaceGB}},@{N="Cluster";E={Get-Cluster -VM $_.Vm.Name}},@{N="vCenter";E={$VC}},FullformattedMessage

}

$Report1 | Out-GridView

 

  

0 Kudos
0 Replies