以编程方式操作 Windows 本地安全策略



我正在寻找一种以编程方式访问和修改PC中的本地组策略设置的方法。

例如,如果我想检查/修改设置的值

"计算机配置\Windows设置\安全设置\本地策略\审核策略\审核登录事件"(路径取自gpedit(,我应该能够通过命令行查询它或设置一个值,而无需gpedit或任何其他本机GUI界面。

我认为可以解决此问题的可能方法是以下两种之一:

1.用于本地组策略设置操作的编程接口

Based on my search 
i. There were no official documentation or tools from Microsoft that could query and manipulate a given setting in Local Security Policy. 
ii. The closest I could get was a vendor named sdmsoftware (Link:- https://sdmsoftware.com/group-policy-management-products/group-policy-automation-engine/) who provides a powershell interface for manipulating the Local group policy. Since the company I work is just a startup, we cant invest on any tools right now. Hence buying something is out of scope.I am looking for a freeware / OSS / any work-around to achive this.

2.映射文件,由映射到相应注册表项或文件路径的所有本地安全设置组成。以便可以使用相同的注册表项或文件直接查询或修改安全设置。

Based on my search 
i. I found a list given by Microsoft which gives a corresponding  registry key to some of the Local Security Policy settings. However , the list does not contain mappings of all Local Security Settings.
(Link:- www . microsoft . com /en - us / download / details . aspx ? id=25250) 

我知道查询任务可以通过使用 gpresult 导出结果并解析它来完成,但无法进行修改。我还尝试测试和分析以下Microsoft工具,通过在 PSmon 等工具下进行监视来以某种方式获取各种本地组策略设置的路径,以查看正在打开的文件和正在查询的注册表等。
(链接 :-technet. 微软.com/en-us/solutionaccelerators/cc835245 .aspx(

b(Microsoft安全合规性工具包 (链接 :-www. 微软.com/en-us/下载/确认.aspx ? id=55319&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1(

然而,它没有产生任何结果,也可能是我可能没有正确分析它们。

我想知道是否有任何文档/文章/用于本地安全策略的免费(免费啤酒(编程接口/任何解决方法,可以让我以编程方式编辑和查询本地组设置。

提前谢谢。

遗憾的是,并非安全设置中的每个设置都可以以相同的方式访问。

如前所述,您可以在注册表中设置大多数设置。如果没有,则在很大程度上取决于您要修改的设置。例如,您可以使用:

  • 审核策略设置.exe。
  • 用户
  • 权限.ps1 用于用户权限分配。

Afaik 没有适用于所有设置的解决方案。如果需要修改其他设置,则应请求此特定设置,以找到其编程方式解决方案。

最新更新