VMware Cloud Community
rgonzalez2
Contributor
Contributor
Jump to solution

Report Powered off Vmware + Date

Hi,

I need a little help. LucD​ Guru of vmware

​i have this script in powershell CLI:

​Connect-VIServer -Server xxxxx -User 'xxxx@vsphere.local' -Password 'xxxxx'

$vms = Get-VM

Foreach ( $vm in $vms ) {

   Write-Output ("")

   Write-Output ("> Nombre VM: " +  $vm.Name)

   Write-Output ("> On/Off: " + $vm.PowerState)

   Write-Output ("> Fecha: " + $lastPO.CreatedTime)

}

Disconnect-VIServer * -Confirm:$false

​But, i dont know why, the Time dont found. for example

​> Nombre VM: (xxxxxxxx)

>On/Off: PoweredOff

> Fecha:

​the "fecha" is empty

​Why can i resolve this?

​the idea is export to HTML or CSV, but this is secundary.

​thanks a lot

Tags (2)
Reply
0 Kudos
23 Replies
rgonzalez2
Contributor
Contributor
Jump to solution

pastedImage_0.png

30 days?

i have in my report 270 VM, its too for a 1 month

Reply
0 Kudos
rgonzalez2
Contributor
Contributor
Jump to solution

Both report the same. 270 VM but... in 1 month its too i think

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, so you keep events for 30 days.
There is no point, in that case, going back further than 30 days.

Just to clarify, is that 99999  or -99999?

The minus sign makes a difference.


And what makes you think that 270 VMs is too much?
Don't you have 270 VMs in your environment?

Or do you see the same VM multiple times in the report?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
rgonzalez2
Contributor
Contributor
Jump to solution

Yes, I have more than 270 vm, but it seems strange that I turned off 270 in just one month.

-The value is 99999 or -7, I've left it at 99999

-The report is fine, none is repeated

But it is working because I just removed a shutdown and it no longer appears in the following report.


					
				
			
			
				
			
			
			
			
			
			
			
		
Reply
0 Kudos