2

From an Administrator PowerShell, is there a way to spawn another shell (or .exe) under a different (for instance, non-administrator) user? I know this is possible in Linux/Bash via su {username}, but does Windows allow it?

This question has been answered for C++ here and for C# here, but I would like to know if it is possible in PowerShell.

Community
  • 1
  • 1
NH.
  • 2,240
  • 2
  • 23
  • 37
  • 1
    Not sure if you meant by this or not: `runas /trustlevel:0x20000 "powershell.exe -command 'hostname'` – Ranadip Dutta May 05 '17 at 15:57
  • Yes, slap a final quote mark on that and then convert it to an answer. I'm also curious what the different trustlevels are, but it looks like 0x40000 is some sort of admin. – NH. May 05 '17 at 16:30
  • Note that this [doesn't completely remove elevated privileges from the child.](http://stackoverflow.com/a/30970434/886887) – Harry Johnston May 06 '17 at 00:16
  • See: http://stackoverflow.com/questions/40863475/starting-non-elevated-prompt-from-elevated-session/40868875#40868875 – iRon May 06 '17 at 18:20
  • Thanks, @iRon. Would be duplicate except it doesn't have accepted answer. – NH. May 08 '17 at 16:02

1 Answers1

0

Try this:

runas /trustlevel:0x20000 "powershell.exe -command 'hostname'"
Ranadip Dutta
  • 8,857
  • 3
  • 29
  • 45