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.
相关问题
- How to Debug/Register a Permanent WMI Event Which
- Django check user group permissions
- How can I do variable substitution in a here-strin
- How to use a default value with parameter sets in
- Does powershell have a method_missing()?
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- C#调用PowerShell的问题
- EscapeDataString having differing behaviour betwee
- Is there a non-java, cross platform way to launch
- Flutter - http.get fails on macos build target: Co
- PowerShell Change owner of files and folders
- Command line escaping single quote for PowerShell
- Is there a simple way to pass specific *named* Pow
if you are using V2, you can use the following which is up on the PowerShell Team Blog
This would run "Get-Process" as administrator.
If you don't have V2, you could create a StartInfo object and set the Verb to Runas like this.
I have a blog post that talks a bit more about using a System.Diagnostics.ProcessStartInfo object.
It sounds like you are looking for a sudo equivalent in windows. Sudo is not inherent to Windows as it is to most Unix style environments. But there are several tools available that are close equivalents.
Be wary when using these types of tools though. An unhardened script + sudo is a security risk.
first
choco install pscx
via http://chocolatey.org/ (you may have to restart your shell environment)then enable psxc
Then use
Invoke-Elevated
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.
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.
The Powershell Community Extensions include a cmdlet for this, alias 'su'. http://www.codeplex.com/Pscx