Solved

Get uptime for multiple VMs

Posted on 2010-11-26
5
1,211 Views
Last Modified: 2012-05-10
Hi experts

I need to get a list of all powered on VMs and their current uptime. I thought this was trivial, but I havent been able to find a solution yet. Have spent some time with Google...

Hope someone can help

I have this, and need to add uptime:
get-vm | where {$_.PowerState -eq "PoweredOn"} | select Name, PowerState, Host

Open in new window

0
Comment
Question by:Bogeholm
  • 2
5 Comments
 
LVL 5

Expert Comment

by:Blake_1
ID: 34220865
You can achieve this by using PowerCLI to return the state of the servers and WMI to query the Operating System uptime (assuming this is the figure that you're after).

NB I haven't tested this script so the syntax may be wrong or it may not even work at all.  But it should put you on the right track.
get-vm | where { $_.PowerState -eq "PoweredOn" } | % { $objUptime = (Get-WmiObject -computer $_.Name -class Win32_PerfFormattedData_PerfOS_System).SystemUpTime ; $_ | select Name,PowerState,@{Name="Uptime";Expression={$objUptime}} }

Open in new window

0
 
LVL 3

Author Comment

by:Bogeholm
ID: 34222776
Thank you Blake1,

Could be an option, but my vCenter is not allowed to access the production network (virtuel machine network).
So I will not be able to use a WMI query against the VM. At the moment i execute the PS from the vCenter server - I do not have other options at the moment.
That is why I hope to do the job strictly in the vmware environment.

I'm reading the below from vmware communities, and have thus moved a bit closer to a solution:
http://communities.vmware.com/message/1304549

But instead of the Boottime I need the uptime (prefer counted in days)
0
 
LVL 5

Accepted Solution

by:
Blake_1 earned 500 total points
ID: 34223908
You can use New-Timespan to calculate the time difference between Get-Date (now) and Boottime.
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34497724
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If we need to check who deleted a Virtual Machine from our vCenter. Looking this task in logs can be painful and spend lot of time, so the best way to check this is in the vCenter DB. Just connect to vCenter DB(default DB should be VCDB and using…
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…
This video shows you how to use a vSphere client to connect to your ESX host as the root user. Demonstrates the basic connection of bypassing certification set up. Demonstrates how to access the traditional view to begin managing your virtual mac…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now