In short, PowerCLI is a Windows PowerShell interface for managing VMware vSphere. It comes with a lot of useful cmdlets that will help you manipulate your VMWare infrastructure smoothly and painlessly (sort of) including automating tasks.
Here is how I can generate a snapshots report of all the virtual machines in my VMWare 6 environment:
1. In a Windows Server 2008 R2 SP1 (or Windows 7 and above), install these dependencies:
Download the latest PowerCLI here.
It's PowerCLI 6 R3 at the time I write this article.
3. Open PowerCLI and set the ExecutionPolicy to RemoteSigned:
For more information about ExecutionPolicy, please read this article: here.
4. Download this script and put it into C:\report_snapshots.ps1
5. Modify the following information in the script:
$Key = [byte]57,86,31,23,73,75,85,52,77,33,0,21,56,76,99,14
# these following information you can pass to the running script but I refer put them directly into the file
[string]$VIServer = "Your vCenter Server",
[string]$Admin = "youradminaccount",
[string]$PathToCredentials = "/path/to/your/credential/file",
[string]$PathToReport = "/path/to/report/file.html",
[string]$From = "Notification Email <email@example.com>",
[string]$SMTPServer = "smtp.gmail.com",
[string]$SMTPPort = "587",
[string]$SMTPPasswd = "yourGMailPass",
[string]$SMTPUser = "yourGMailUser"
$TO_ADDR = "firstname.lastname@example.org", "email@example.com", "firstname.lastname@example.org"
6. In PowerCLI unblock the downloaded script with the following command:
7. Run the script the first time in PowerCLI to create the credential file:
It will open a dialog and ask for your admin credential.
8. In Task Scheduler, create a task to run this command at every Thursday at 1AM (or anytime you want):
powershell -file "C:\report_snapshots.ps1"