vCheck is a community project started few years back by Alan Renouf. Since then it has been enhanced and updated several times, with the latest version 6 of the script recently enhanced and shared now at GitHub where the collaborative environment can be leveraged for further improvements.
So How to run vCheck? There is possibility to run vCheck directly by executing the powershell script, or you can make the execution via scheduled task. The scheduled task might be tricky to make it works, but once done you'll be just receiving the daily report via e-mail.
How to run vCheck interactively
- Download the latest PowerCLI from VMware website.
- Download PowerShell 3.0 from Microsoft (should work), if not use PowerShell 2.0
- Run the PowerCLI from start menu and connect to your vCenter server (or host, if you don't have vCenter in your environment) by using the command Connect-VIServer
- Run the … .\vCheck.ps1 from within your PowerCLI window and follow the assistant to configure how the script will run for the first time. The second time you run the script there isn't any input necessary. I've embedded a video from Alan Renouf at the end of this post, so you can follow….
How to run vCheck as a Scheduled task
Create a batch file – which will be saved as *.cmd
To run vCheck as scheduled task, there is a long command line a to pass. It looks like this. To make it work, just test it through the DOS window:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1″ ” & “C:\Scripts\MyScript.ps1″
Note that if you get an error saying that:
Windows PowerShell console file “”C:\Program” extension is not psc1. Windows PowerShell console file extension must be psc1
You may need to adjust the script, as in some environments there seems to be issues, like you can note that by adding an additional “quote” before the & migh help…
Alternatively, go directly to the Task Scheduler
On the ‘Actions’ tab select the action ‘Start a program’
The Program/script is (no quotes):
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
The ‘Add arguments (optional)’ box contains:
-psconsolefile “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1″ -file C:\Scripts\vCheck.ps1 vcenter.testing.local
The ‘Start in’ box is blank.
Quick Tip:
If you're not sure which version of PowerCLI you're running, just quickly enter Get-PowerCLIVersion
Bonus:
- PowerCLI poster can be found on https://vmware.com/go/powercli.
- More Free tools and posters – check out our Free VMware Tools page
Video done by Alan Renouf:
Sources:
- Dimitry Sotnikov
- Alan Renouf – vCheck Daily Report
- VMware Forums
Paul Crane says
This scheduled tasked worked for me on Windows Server 2008 R2
Program\Script:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments (optional):
-psc “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1″ -noe -c “.\”C:\vcheck\vcheck.ps1\””
Javed says
vcheck 6.15 script is working fine on windows 2008 R2. But when i run this script on Windows 2012 it gives me this error
“Connect-VIServer : The term ‘Connect-VIServer’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\vCenter_Check0.1\Plugins\00 Connection Plugin for vCenter.ps1:26 char:17
+ $VIConnection = Connect-VIServer $VIServer –user “xyz.com\testuser” – …
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-VIServer:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException”
Some have seen this issues on Windsows 2012
Fletcher Cocquyt says
Just had a coworker want to run my deployVM PowerCLI script – he’s on a MAC, so I upgrade the shared windows server from 5.5 (where my scheduled vchecks reports run daily) to 6.x powercli
Now I am looking for advice how to update my windoze scheduled job command lines:
Old 5.5:
powershell.exe -PSConsoleFile “c:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” -file “e:\vmware\vCheck-snapreport\vcheck.ps1”
New 6.x: ?
I am getting the error:
E:\vmware\vCheck-snapreport>e:\vmware\vCheck-snapreport\vcheck.ps1
PS E:\vmware\vCheck-snapreport> .\runvcheck-new.bat
E:\vmware\vCheck-snapreport>REM powershell.exe -PSConsoleFile “c:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” -file “e:\vmware\vCheck-snapreport\vcheck.ps1”
E:\vmware\vCheck-snapreport>REM upgraded to PowerCLI 6.5 – simpler syntax
E:\vmware\vCheck-snapreport>REM C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c “. \”C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\” $true” -file e:\vmware\vCheck-snapreport\vcheck.ps1
E:\vmware\vCheck-snapreport>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe e:\vmware\vCheck-snapreport\vcheck.ps1
Begin Plugin Processing
[10:22:53] ..start calculating Connection settings for vCenter by Alan Renouf v1.7 [1 of 13]
[10:22:53] Connecting to VI Server: cdgparpr01vcn55.cdg.ssnsgs.net
Connect-VIServer : The term ‘Connect-VIServer’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At E:\vmware\vCheck-snapreport\Plugins\00 Initialize\00 Connection Plugin for CDGPR01.ps1:66 char:18
+ $VIConnection = Connect-VIServer -Server $VIServer -Port $Port
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-VIServer:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
E:\vmware\vCheck-snapreport\Plugins\00 Initialize\00 Connection Plugin for CDGPR01.ps1 : Unable to connect to vCenter, please ensure you have altered the vCenter server address correctly. To specify a username and password edit the connection string in the file $GlobalVariables
At E:\vmware\vCheck-snapreport\vcheck.ps1:670 char:54
+ $TTR = [math]::round((Measure-Command {$Details = . $_.FullName}).TotalSecond …
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,00 Connection Plugin for CDGPR01.ps1
[10:22:53] Adding Custom properties
New-VIProperty : The term ‘New-VIProperty’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At E:\vmware\vCheck-snapreport\Plugins\00 Initialize\00 Connection Plugin for CDGPR01.ps1:102 char:1
+ New-VIProperty -Name LastPoweredOffDate -ObjectType VirtualMachine -Value {(Get- …
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-VIProperty:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
New-VIProperty : The term ‘New-VIProperty’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At E:\vmware\vCheck-snapreport\Plugins\00 Initialize\00 Connection Plugin for CDGPR01.ps1:103 char:1
+ New-VIProperty -Name LastPoweredOnDate -ObjectType VirtualMachine -Value {(Get-V …
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-VIProperty:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
New-VIProperty : The term ‘New-VIProperty’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At E:\vmware\vCheck-snapreport\Plugins\00 Initialize\00 Connection Plugin for CDGPR01.ps1:105 char:1
+ New-VIProperty -Name PercentFree -ObjectType Datastore -Value {
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-VIProperty:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
any advice?
Srikanth says
Can you advise how we can run vCheck on Multiple vcenters and getting these reports on a Single email?
Avi Benemanuel says
update for those who find this page and the task scheduler doesn’t work for them.
this is what I did to get things working
1. edit Plugins\00 Initialize\00 Connection Plugin for vCenter.ps1
added before # Adding PowerCLI core snapin (which for some reason didn’t work)
if ( !(Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) ) {
. “C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1”
}
2. task changed to
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe “vCheck-vSphere-master\vCheck-vSphere-master\vcheck.ps1”
3. recreated the credential file
New-VICredentialStoreItem -Host -user -Password -File “vCheck-vSphere-master\vCheck-vSphere-master\Windowscreds.xml”
Tom says
This looks amazing? Is there any risk to running this on a large environment (80 Hosts, 500VMs)? It only PULLS information, correct? Doesn’t try to change anything?
Thanks
Vladan SEGET says
Hi Tom, the only risk is that the script will take a long time to run. -:) Yes, only reads values.
Ramesh Badam says
Hi Alan, Frederic,
I have enabled ‘VMKernel warnings’ plugin and renamed the PS script file as well however I did not get the report output. Could you please advise how to enable this to get a report