如何从提升的PowerShell控制台以非管理员身份运行进程? [英] How to run a process as non-admin from an elevated PowerShell console?

查看:428
本文介绍了如何从提升的PowerShell控制台以非管理员身份运行进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许有一种方法可以使用启动过程我找不到的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆