Solved

Get uptime for multiple VMs

Posted on 2010-11-26
5
1,388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 71

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Suggested Solutions

A brief introduction to what I consider to be the best editor for PowerShell.
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Teach the user how to install log collectors and how to configure ESXi 5.5 for remote logging Open console session and mount vCenter Server installer: Install vSphere Core Dump Collector: Install vSphere Syslog Collector: Open vSphere Client: Config…
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…

752 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