Solved

Get uptime for multiple VMs

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
Giving access to ESXi shell console is always an issue for IT departments to other Teams, or Projects. We need to find a way so that teams can use ESXTOP for their POCs, or tests without giving them the access to ESXi host shell console with a root …
Teach the user how to rename, unmount, delete and upgrade VMFS datastores. Open vSphere Web Client: Rename VMFS and NFS datastores: Upgrade VMFS-3 volume to VMFS-5: Unmount VMFS datastore: Delete a VMFS datastore:
This video shows you how easy it is to boot from ISO images for virtual machines with the ISO images stored on a local datastore on the ESXi host.
Suggested Courses

623 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