r/PowerShell • u/No-Orange-4073 • Jun 22 '26
Question Running a scrip as non admin
Hello all,
I have a situation where I have a script that is running with elevated (admin) rights. At the end of it I need to start another script, but need this to be with non arming rights.
Start process
Shell
Everything that I have tried opens a new one with inherited admin rights.
Hope someone can help.
1
Upvotes
5
u/BlackV Jun 22 '26
Start the other way
2
u/leftcoastbeard Jun 22 '26
I would say use a scheduled task, but that may involve some additional setup to work with the non-admin account.
1
u/riazzzz Jun 22 '26
If nothing else works many management and software management platforms have scripts you could review / be inspired by, for relaunching processes in user context.
Below is an Action 1 variant but there is also one I have used in the past in PSAppDeploymentToolKit.
https://github.com/Action1Corp/EndpointScripts/blob/main/RunAsLoggedOnUserContext.ps1
1
u/surfingoldelephant Jun 22 '26 edited Jun 22 '26
Jborean93's
ProcessExmodule can do this.You can specify the parent of the spawned process using
Start-ProcessEx -StartupInfo. If you pass it info onexplorerfor the current user session, the spawned process will be unelevated.First get the right
explorerinstance:Then spawn a new PowerShell process using
explorer's startup info:If you want to inline the process so that standard output/error can be captured (like with the call operator/native commands), use
Invoke-ProcessExinstead.1
u/Future-Remote-4630 Jun 23 '26
You could subscribe the script to an event in the user context, then have your admin script throw that event to trigger the user context script.
0
u/purplemonkeymad Jun 22 '26
What is the context of running the first script? Normally I would just run a user space script where it prompts for the admin account details when running that part ie: