Powershell script Get-WmiObject command not run from Task Scheduler

114 Views Asked by At

we have "Access Denied" error, when running the PS script from Task Scheduler, but it works fine when running directly from PS shell.
Even we are running command with localhost, we configured DCOM and WMI permissions similarly as in this article.
User was also granted "Log on as a batch job" permission via Local Security Policy.
Concern command:

Get-WmiObject Win32_Service -Filter "Name Like '%<service_name>%'"

Task scheduler is configured like below:

powershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file "name_of_script.ps1"
0

There are 0 best solutions below