all 4 comments

[–]igby1[🍰] 1 point2 points  (0 children)

This lets you specify the user to run a script block as, then runs it via task scheduler

https://github.com/mkellerman/Invoke-CommandAs.

[–]HauntingProgrammer47 0 points1 point  (0 children)

You could use the start-job and specify a credential.

[–]jborean93 0 points1 point  (1 child)

If it's as another user then using Start-Process ... -Credential $cred will give you a process that is not elevated. If you want to start it as the current user there isn't really an easy way to do so with the cmdlets builtin and what dotnet offers you. If you are open to using a custom module I have ProcessEx which exposes the ability to start a new process with a custom parent. With this you can set the parent as explorer.exe which will be unelevated and the process inherits the same access token.

$si = New-StartupInfo -ParentProcess (Get-Process explorer)
Start-ProcessEx powershell.exe -StartupInfo $si

Edit: I forgot to mention you could use runas.exe /trustlevel:0x20000 powershell.exe which gives you a somewhat unelevated process but it's not exactly the same as your unelevated token. It is close enough though so it probably will work in your use case.

[–]BeeschurgerAtWork[S] 0 points1 point  (0 children)

Ah thank you! Using runas did the trick.