This is the simple script I am running:
---Begin Script---
#Script for reporting on VM information and Inventory.
add-pssnapin VMware.VimAutomation.Core
Connect-VIServer -Server VCENTESERVERNAME.Domain
Get-VM | select Name, Notes, Folder, PowerState, Version, NumCpu, MemoryGB, UsedSpaceGB, ProvisionedSpaceGB | sort Notes | Export-Csv -path "C:\_VMware_Scripts\vminventory_$((Get-Date).ToString('MM-dd-yyyy')).csv" -NoTypeInformation
---End Script---
---Begin Scheduled Task---
The script runs in the local PowerCLI console but when scheduling it there are no results.
the windows task scheduler is set as:
Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add Arguments: -PSConsoleFile “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" “& ‘C:\_VMware_Scripts\GetVMInventory.ps1′”
---End Scheduled Task---
The scheduled task fails with (0xFFFC0000)
The account it is using is the same domain account that runs the script locally.
It is running from the local vsphere console install server.
I have tried all things I could find.
Any help greatly appreciated.
Thank You.
Did you already try switching off verbose messages ?
You can do
$VerbosePreference = 'SilentlyContinue'
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I had trouble getting mine to run as scheduled tasks as well. Here's what I wound up doing.
I actually pointed the scheduled task to a CMD file without using anything in the arguments box. So, for me the schedule task just points to C:\PowerCLI\ScriptName.cmd
Then, the contents of the CMD are as follows:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "&" "C:\PowerCLI\ScriptFile.ps1"
i tried identical .. no luck
i have a windows 7 os
You can try outputting to a log file to determine the issue.
Change the CMD file contents to (obviously adjusting paths/filenames where appropriate):
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "&" "C:\PowerCLI\ScriptFile.ps1 -verbose >> C:\PowerCLI\OutputLog.log 2>&1"