Open Ankoji opened 6 years ago
Anyone Please help on this issue
Had the same issue when trying to run the task under SYSTEM. Set it to use a service account and that got it running.
-noe
as an argument to PowerShell.exe means noexit. Remove it from your task arguments so you don't have to forcibly stop the task.
Other suggestions for vCheck as a scheduled task:
PowerShell.exe
in Program/Script works for me on Win2012 (non-R2).-NoProfile -File "<path>\vCheck.ps1"
(I also have -ExecutionPolicy AllSigned because I sign all the *.ps1 files in my vCheck directory. You may need to add -ExecutionPolicy RemoteSigned)To troubleshoot this you can amend the vCheck.ps1 as follows: At this point:
$vCheckVersion = "6.25"
$Date = Get-Date
Add this line:
Start-Transcript -Path ('c:\PATH-TO-LOG-FILE\vCheckTask.{1:yyyy-MM-dd}.log' -f $env:temp, $Date)
Then at the very bottom of the script add the following:
Stop-Transcript
(replace the path as you require)
Examining the log output will probably tell you why it's failing. For me it was failing to log into vCenter as I was running on another server under System
@gregharms Is it possible to run the check using system user? While i execute the script in powershell it works fine also when i schedule the task and run as my user it works fine.. But when i schedule it as task and run as system it fails. Checking the log i could see that it was not login into v-sphere. Could you please help?
I am having an issue getting vCheck to run as a scheduled task. I have a Service Account setup and have given that user Admin rights on the server.
My environment:
2 vCenter currently (Enhanced Linked Mode)
vCenter 6.7
vSphere 6.5
PowerCLI 11.5
PowerShell 5.1
Windows 2019
If I run it manually it works as expected. When I try to run it as a Scheduled Task, it says ran successfully, but I get nothing from it. I am sure that where I am having the issue is in the Action part of the task.
Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Add Argument: -c ". \"C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\" $true" "C:\PowerShell-Scripts\vCheck-vSphere-master\vcsa-lab\vCheck.ps1"
I have tried changing the Add Argument with the -PSConsoleFile and vim.psc1, but that doesn't work at all.
I am not sure how to get it to run. I don't want to run it manually everyday.
I was able to get it to work by putting it in a batch file and running it.
pardon the necro-bump.
@Scepticalist 's comment was very useful. No matter what i did. my old copy of vCheck failed on Win11 even though it worked on Win10 verbatim for years. Even via exporting/importing the Task Scheduler XML and using the same domain account, the transcript-log reported access denied regardless of task's action methods (batchfile, non-batchfile, privileges, etc.).
To circumvent the problem, I added the following code near the beginning of 00 Initialize/00 Connection Plugin for vCenter.ps1
after setting the normal vCenter $Server
variable, which worked:
Connect-VIServer -Server $Server -Protocol https -Force
I cannot determine why 00 Initialize/00 Connection Plugin for vCenter.ps1
is not working as expected as there were no changes whatsoever. It may be the $OpenConnection = $global:DefaultVIServers | Where-Object { $_.Name -eq $VIServer }
line, but i did not troubleshoot further. Maybe such is obsoleted in newer PowerShell/PowerCLI.
I hope this helps someone in lieu of vCheck being stale (https://github.com/alanrenouf/vCheck-vSphere/issues/746) . or maybe someone might point out some other resolution not thought of. Thank you.
Edit: Pertinent, but should not be a factor, is that my config uses a service-account with local security policy for Log on as a batch file
and vCenter read-only rights.
Hi Alan. Need your Help. I am trying to run vCheck as scheduled task. I have created the task in the scheduler to run daily. The task gets started and shows as running and never gives the output. I had to forcefully end the task after 1 hours. Below is how my action window looks in the task scheduler.
My environment:
vCheck v6.25 Powershell 5.1.14409 PowerCLI 6.3 Realease 2 vCenter 6.0 Update3
Aside from this I can run the batch file manually and its working fine and its not asking password during script running . also note schedule task created with same user and running with same user. Batch file contains ( C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c ".\"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\"";D:\Ankoji_Scripts\vSpherevCheck\vcheck.ps1")