I can run vCheck straight form Powershell no problem. However when I add it to a scheduled task I get an email that returns nothing but the following:
Number of Hosts: | 1 |
Number of VMs: | 1 |
Number of Templates: | 1 |
Number of Clusters: | 1 |
Number of Datastores: | 1 |
I of course have many more host etc than this. My task has the following settings:
script:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
arguments:
"C:\scripts\vCheck-vSphere-master\DC2\vCheck.ps1"
I have seen some blog posts regarding this but they all seem out of date. What am I missing?
This thread would probably be better in the PowerCLI area, a moderator should be along to move it there.
Under which account does the Scheduled Task run?
How do you pass the VCSA credentials to vCheck in the Scheduled Task?
Did you use an XML file to specify against which environment vCheck should run?
Which outdated posts are you referring to?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Under which account does the Scheduled Task run? - service account with RO permissions to vcenter
How do you pass the VCSA credentials to vCheck in the Scheduled Task? - no idea
Did you use an XML file to specify against which environment vCheck should run? - no
Which outdated posts are you referring to? - there are many posts about running the powershell and the arguments is powercli or somethign but those folders dont exist and none of that works.
There are many methods of executing PowerCLI/POSH against a vCenter on a scheduled basis, the most common is using a cronjob or scheduled task, as described here https://virtualg.uk/running-powercli-powershell-scripts-as-a-scheduled-task/
If I use the following from the article
I still only get an email sent which has 1 host, VM, Template, Cluster, datastore in the report from general information.
I dont get anything else, so something simply isn't working.
Sounds like the script is running, but not collecting the right data. I'd investigate the logic of the script.
Maybe some command or module isn't being loaded if using an alternate user for the scheduled task?
If I just run the script from powershell it works fine.
My actions for a scheduled task would be
Action: Start a program
Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe
Add Arguments (Optional):-Command c:\path\to\scriptyboy.ps1
edit: i am not a windows guy, sorry