如何从提升的PowerShell控制台以非管理员身份运行进程? [英] How to run a process as non-admin from an elevated PowerShell console?
问题描述
也许有一种方法可以使用启动过程我找不到的cmdlet?我在StackOverflow上找到的其他相关的Q/A,例如 this ,此都提供了使用自定义C#进行此操作的解决方案代码.我的问题特别是,在PowerShell中有没有简单的方法可以做到这一点?也就是说,您在高级PS控制台中,并希望以非管理员身份运行进程.
Maybe there is a way to do it with Start-Process cmdlet that I cannot find? The other related Q/A's I found on StackOverflow such as this, this and this all give a solution to do this with a custom C# code. My question is specifically, is there any straightforward way to do this in PowerShell? i.e. you are in an elevated PS console and want to run a process as non-admin.
推荐答案
您可以用runas.exe
指定TrustLevel
,有效地运行受限"
You can specify the TrustLevel
with runas.exe
, effectively running "restricted"
runas /trustlevel:0x20000 "powershell.exe -command 'whoami /groups |clip'"
您应该在whoami
的输出中看到,令牌中的Administrators
组被标记为仅用于拒绝".
You should see in the output from whoami
that the Administrators
group in your token is marked as "Used for Deny only"
这篇关于如何从提升的PowerShell控制台以非管理员身份运行进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!