可以在 PowerShell 脚本中使用 RunWithElevatedPrivileges 吗? [英] Can RunWithElevatedPrivileges be used in a PowerShell script?

查看:57
本文介绍了可以在 PowerShell 脚本中使用 RunWithElevatedPrivileges 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果是,请举例.

更新:

我有一个 PowerShell 脚本,它遍历所选 Web 应用程序中的所有网站集并更改 siteCollection.Audit.AuditFlags 属性.它在我的开发机器上运行良好,但 siteCollection.Audit.Update() 命令失败并在生产服务器上出现 Access is denied 错误,即使我正在尝试运行作为农场管理员的用户.

I have a PowerShell script that iterates through all site collections within selected Web application and changes the siteCollection.Audit.AuditFlags property. It works fine on my development machine, but the siteCollection.Audit.Update() command fails with Access is denied error on the production server, even though I am trying to run it as a user who is a farm administrator.

推荐答案

以管理员或 webapp 应用程序池用户的身份运行 powershell.

Run powershell as an administrator or as your webapp application pool user.

这篇关于可以在 PowerShell 脚本中使用 RunWithElevatedPrivileges 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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