mkellerman / Invoke-CommandAs

Invoke Command As System/Interactive/GMSA/User on Local/Remote machine & returns PSObjects.

Home Page:https://www.powershellgallery.com/packages/Invoke-CommandAs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't figure out the right amount of permission

mieel opened this issue · comments

I'm having trouble to figure this out for a couple days, I was hoping you might have some insight:

Running this Invoke-CommandAs -ScriptBlock { Write-Output 'Test'} -AsUser $credObject -verbose as a normal user, returns

Invoke-ScheduledTask : Task was unable to be executed.
At C:\Program 
Files\WindowsPowerShell\Modules\Invoke-CommandAs\3.1.6\public\Invoke-CommandAs.ps1:399 char:17
+                 Invoke-ScheduledTask @Parameters

Fair enough, not every user needs to have permission to create Scheduled Tasks.
When I assign log on as a batch job to the user, no errors comes back, but! I get no Output.

Investigating the $error[0] variable I could see that under hoods there was an error: Get-Job : The command cannot find the job because the job name <GUID> was not found. Verify the value of the Name parameter, and then try the command again.

For now, I only got it working if I add the user to the local Adminstrator group.
Any idea what the exact permissions are?

It might be an issue with the user that is used to create the task, has to be the user used to Invoke the Command.

So add: -Credential $credObject

cross fingers

Invoke-CommandAs -ScriptBlock { Write-Output 'Test'} -AsUser $credObject -Credential $credObject -verbose
Invoke-CommandAs : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1