D
D
d3coy_002020-04-20 18:06:31
PowerShell
d3coy_00, 2020-04-20 18:06:31

Problem creating task in taskscheduler via powershell?

I noticed a strange thing: when creating a task in the task scheduler in win 10 manually through gui, everything is created without problems; Nevertheless, automating the creation of a task through powershell, I get a message - Permission denied, although I open powershell from the same user through which I created the task in the scheduler. What is the problem? How to create a task without an account request. data and windows UAC?

Task creation code:

$Trigger= New-ScheduledTaskTrigger -At 10:00am -Daily
$User= "DESKTOP123\user1"
$Action= New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "cmd.exe"
Register-ScheduledTask -TaskName "StartupScript_PS" -Trigger $Trigger -User $User -Action $Action -RunLevel Highest –Force

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxKozlov, 2020-04-20
@d3coy_00

This is because of -RunLevel Highest
when you are running from the GUI windows implicitly gives mmc the right permissions
if you try to create a task with the highest permissions from a non-admin user you will see a UAC prompt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question