Solved

Get uptime for multiple VMs

Posted on 2010-11-26
5
1,129 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When we have a dead host and we lose all connections to the ESXi, and we need to find a way to move all VMs from that dead ESXi host.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
Teach the user how to delpoy the vCenter Server Appliance and how to configure its network settings Deploy OVF: Open VM console and configure networking:
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

762 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

19 Experts available now in Live!

Get 1:1 Help Now