简体   繁体   English

如何使用 C# 通过组策略检查 PowerShell 禁用

[英]How to check PowerShell disable by group policy using C#

How can I fetch the details of PowerShell enabled or disabled by group policy using C#?如何使用 C# 获取组策略启用或禁用的 PowerShell 的详细信息?

There is a limitation called ExecutionPolicy , setting, which can prevent from running scripts from files.有一个称为ExecutionPolicy的限制设置,可以防止从文件运行脚本。

From C#, you can create an instance of InitialSessionState with ExecutionPolicy = ByPass and create Powershell with this initial session state. From C#, you can create an instance of InitialSessionState with ExecutionPolicy = ByPass and create Powershell with this initial session state. Then try to run your script file with Invoke-Command -FilePath command .然后尝试使用Invoke-Command -FilePath command运行您的脚本文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM