PowerCLI: Report every VM added to vCenter in the last 30 days: Difference between revisions

From VI-Toolkit
Jump to navigation Jump to search
(New page: At seemingly random intervals I get requests from management to report every Virtual Machine that was added/removed in the last x days. This has traditionally been a manual process, and on...)
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
At seemingly random intervals I get requests from management to report every Virtual Machine that was added/removed in the last x days. This has traditionally been a manual process, and one that I loath.
By using the PowerCLI and VMware's SDK it is entirely possible to query the history of tasks and events.  One of the data gems that can be garnered from the event history is when virtual machines have been created or deleted.


While deploying a VM this morning I set up my normal tell me when your done one-liner…
You can find how to query the event history [http://get-admin.com/blog/?p=725 here].
 
Get-Task|?{$_.Name -eq "CloneVM_Task"}|Wait-Task; `a`a`a
 
As I was typing I wondered how long a task’s history was kept, and if I could query it via the SDK? Low and behold not only can I but it’s too easy!
 
http://get-admin.com/blog/?p=725


[[Category: Powershell]] [[Category:PowerCLI]]
[[Category: Powershell]] [[Category:PowerCLI]]

Latest revision as of 16:50, 23 July 2009

By using the PowerCLI and VMware's SDK it is entirely possible to query the history of tasks and events. One of the data gems that can be garnered from the event history is when virtual machines have been created or deleted.

You can find how to query the event history here.