VMware vSphere - PowerCLI Script - Export List of VM Name and Last Logon


I'm trying to find a PowerCLI script that I can run on my vCenter environment to get a list of all the VM's and when it was last logged into and by whom if possible.

I'm not that good at scripting so if someone could provide the code and explain what I would have to input to get this done that would be great.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In the last script link I provided you at http://www.experts-exchange.com/Software/VMWare/Q_28337757.html , take of one of the event and replace it with


That will get you the last logon information of all VM's
LumiousAuthor Commented:

Abhilash Hb:

As discussed here:


Please let me know how to go about this next one.

Was just looking at the events. You can only pull the details of the last powered on. I do not see any last logon event.
LumiousAuthor Commented:

If we are sure that it's not able to find those results, then lets see if we are able to do "last powered on" instead which should be sufficient for the reporting I'm doing.

Please let me know.

Its very easy that way.
Download this tool called RVtools

Run it against your vCenter. It will generate an extensive report of all the possible things you need. Including Power on event which can be found under vInfo called as PowerOn.

Let me know if that is enough. Also you can export the report into EXcel,CSV  etc.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.