如何使用power shell脚本为本地组策略(gpedit.msc)设置值

时间:2017-03-26 17:41:42

标签: powershell group-policy

我想在本地组策略编辑器中访问此路径Computer Configuration\Policies\Windows Settings\Security Settings\Account Policies\Password Policy\Maximum password age,并通过powershell脚本修改其值。我试图导入模块组(Get-Command -Module group*)但没有找到方法/模块。我在powershell中尝试了以下方法,但它没有工作。

Set-ItemProperty -Path \Computer Configuration\Windows Settings\Security Settings\Account Policies\Password Policy -Name Maximum password age -Value 20

有人可以通过PowerShell脚本来帮助我修改价值。

  

我是PowerShell脚本的新手,所以如果有任何错误的信息,请忽略   提供。

3 个答案:

答案 0 :(得分:0)

您可以在Windows注册表中找到它,HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ Netlogon \ Parameters MaximumPasswordAge REG_DWORD

答案 1 :(得分:0)

您可以使用[get / set] -itemproperty命令有点反直觉地获取/设置注册表值。

示例:

    VideoCapture vcap;

     const string videoStreamAddress = "udp://" + "(my Ipv6 address)" + ":2222";

 vcap.open(videoStreamAddress);

但是,这可能不会反映在“本地组策略编辑器”界面中。

查找LGPO.exe,文档虽然很少,但似乎可以使用: https://blogs.technet.microsoft.com/secguide/2016/01/21/lgpo-exe-local-group-policy-object-utility-v1-0/

(当前下载位于“安全合规性工具包”中) https://www.microsoft.com/en-us/download/details.aspx?id=55319

答案 2 :(得分:-1)

对于像max password age这样的参数,我认为最好的方法是使用net.exe commant。尝试执行

net.exe accounts /? 

对于没有域的计算机中更复杂的组策略,您可以使用secedit.exe在一台计算机中准备策略,将其导出到文件以及在其他计算机中导入

尝试google secedit / export,secedit / import usage

你可以毫无问题地从powershell调用secedit