提升Powershell脚本 [英] Elevate Powershell scripts

查看:72
本文介绍了提升Powershell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以提升Powershell脚本的权限,以便没有管理员权限的用户可以运行该脚本?我们的网络管理员正在尝试找到更多省时的方法来完成某些任务,而现在他们不得不使用远程桌面...使用PS脚本自动化它们会有所帮助,但是用户没有管理员权限.

Is it possible to elevate the permissions of a powershell script so a user without admin privileges can run the script? Our network admins are trying to find more time-efficient ways to accomplish certain tasks that right now they have to use remote desktop for...automating them with PS scripts would help, but the users don't have admin rights.

推荐答案

任务更像是setuid,而不是sudo ...而且值得庆幸的是,setuid 是可能的:您可以简单地创建计划任务( (未设置时间表)),并将其设置为提升.然后,授予您的用户执行该任务的权限.我概述了该过程

The task is more like setuid than sudo ... and thankfully, setuid is possible: you can simply create a scheduled task (without a set schedule), and set it to run elevated. Then, give your users rights to execute that task. I outlined the process in a blog post awhile ago along with a PowerShell script to help create the tasks and shortcuts to run them.

问题(如JaredPar所建议的)是,必须确保计划运行提升版或以管理员身份"运行的应用程序受到保护,如果要运行脚本,则尤其如此.确保只有管理员才能编辑或替换该脚本,否则您将没有给王国的众所周知的钥匙.

The problem (as JaredPar suggested) is that you have to make sure that the apps which you have scheduled to run elevated or "as administrator" are protected, and this is especially true if you will run a script. Make sure noone but the administrator(s) can edit or replace that script, or you're giving away the proverbial keys to the kingdom.

这篇关于提升Powershell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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