Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 175326

Need to get Vcenter info

$
0
0

Hello - I'm trying to get vcenter name as i'm running below script across multiple vcenter.

 

Command: $csvline.vcenter = $event.VC.name not giving me vcenter name. please advise.

 

Script:

 

Import-Module VMware.VimAutomation.Core

Connect-VIServer vcenter

$report = @()

 

$events = Get-VIEvent -maxsamples 10000 -Start (Get-Date).AddDays(–5) | where {$_.Gettype().Name-eq "VmCreatedEvent" -or $_.Gettype().Name-eq "VmBeingClonedEvent" -or $_.Gettype().Name-eq "VmBeingDeployedEvent" }

 

foreach ($event in $events)

{

$csvline = "" | Select EventTime, Datacenter, Cluster, VM, Description, vcenter

$csvline.EventTime = $event.CreatedTime

$csvline.Datacenter = $event.Datacenter.Name

$csvline.Cluster = $event.ComputeResource.Name

$csvline.VM = $event.VM.Name

$csvline.Description = $event.FullFormattedMessage

$csvline.vcenter = $event.VC.name

$report += $csvline

}

$report | Export-csv -NoTypeInformation E:\output_file.csv

 

Thank you!!


Viewing all articles
Browse latest Browse all 175326

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>