I am working on script which would provide the vCenter version and build, no of session over xdays , roles&users mapping and list of roles and privileges associated on each vCenter. I have few one liner to get them, Need help to coming them into single script and export them to a CSV file.
Using the below to get vCenter version info
$global:DefaultVIServers | Select Version,build
below is used to get the roles and group associated with them
Get-VIPermission | select Principal, Role, Entity, Propagate
Working on the below to get the number of session over Xdays
$OlderDays = 1
$serviceInstance = Get-View 'ServiceInstance'
$sessMgr = Get-View $serviceInstance.Content.sessionManager
$Session = @()
foreach ($sess in $sessMgr.SessionList) {
($sess.LastActiveTime).addDays($OlderDays) -lt (Get-Date) }
($Session | Measure-Object).Count
Thanks!!
If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful |Blog: http://aravindsivaraman.com/ | Twitter : ss_aravind