简体   繁体   English

如何创建用户组并通过Powershell / cmd Windows Server 2012 R2将组策略链接到他们

[英]How to create group of users and link group policy to them via powershell/cmd Windows Server 2012 R2

Is there a way to create group of users with group policy apllied to them via Powershell/CMD? 是否可以通过Powershell / CMD创建具有组策略的用户组? My machine is not joined to a domain. 我的机器未加入域。 I want to prepare a script which I will use multiple times on other local computers/ machines to recreate group policy. 我想准备一个脚本,该脚本将在其他本地计算机/计算机上多次使用,以重新创建组策略。 I want eg restrict user access to Control Panel, Internet Access and stuff like that. 我想例如限制用户访问控制面板,Internet访问和类似的东西。

Thanks from advance for answers 感谢预先提供的答案

For computers not joined to the domain, you can't use Group Policy. 对于未加入域的计算机,您不能使用组策略。 You will need to use Local Policy. 您将需要使用本地策略。 Many of the items that you are looking for will simply be registry value that you can easily set with a PowerShell script. 您要查找的许多项目都只是注册表值,您可以使用PowerShell脚本轻松设置。 For example the policy for Hiding Fast User Switching toggles can be toggled like this: 例如,可以像下面这样切换“隐藏快速用户切换”切换的策略:

Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name HideFastUserSwitching -Value 0

You can look up where the values are by reading the .admx templates 您可以通过阅读.admx模板来查找值的位置

Alternatively you could use David Wyatt's PowerShell module to read and modify policy files. 或者,您可以使用David Wyatt的PowerShell模块来读取和修改策略文件。

Finally the last option would be create the policy on one computer and then overwrite the .pol files on all the computers and then gpupdate /force . 最后,最后一个选择是在一台计算机上创建策略,然后覆盖所有计算机上的.pol文件,然后覆盖gpupdate /force This of course could be scripted with PowerShell. 当然,可以使用PowerShell编写脚本。

Copy-Item \\ExampleComputer1\C$\Windows\System32\GroupPolicy\Machine\Registry.pol \\ExampleComputer2\C$\Windows\System32\GroupPolicy\Machine\Registry.pol -Force
Copy-Item \\ExampleComputer1\C$\Windows\System32\GroupPolicy\User\Registry.pol \\ExampleComputer2\C$\Windows\System32\GroupPolicy\User\Registry.pol -Force

Security Templates would have to be exported from the Security Templates mmc snapin and then imported on the other computers with secedit 安全模板必须从“安全模板” mmc管理单元中导出,然后使用secedit导入到其他计算机上

secedit /configure /db %temp%\temp.sdb /cfg yourcreated.inf

Using that solution --> Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" -Name HideFastUserSwitching -Value 0 使用该解决方案-> Set-ItemProperty -Path“ HKLM:\\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ Policies \\ System”-名称HideFastUserSwitching-值0

Doesn't work. 不起作用 I mean eg: 我的意思是例如:

Set-ItemProperty -Path "HKLM:Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\NonEnum" -Name NoRecycleBinIcon -Value 1 Set-ItemProperty -Path“ HKLM:Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Policies \\ NonEnum”-名称NoRecycleBinIcon-值1

.admx template. .admx模板。

It should make my desktop recyclebin gone. 它应该使我的桌面回收站消失了。 This is just an example other settings also stays unchanged. 这只是一个示例,其他设置也保持不变。

暂无
暂无

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

相关问题 在 windows server 2008 r2 上使用 csv 文件将 AD 用户添加到安全组 - Adding AD users to security group using a csv file using powershell on windows server 2008 r2 如何在Windows Server 2008 R2上通过Powershell 4.0创建计划任务? - How can I create scheduled tasks via Powershell 4.0 on Windows Server 2008 R2? 在Powershell中,如何检索现有策略设置(Win8.1 / Server 2012 R2 Core) - In Powershell, how to retrieve existing policy settings (Win8.1/server 2012 r2 core) Windows Server 2012 R2:通过 PowerShell 从 Microsoft Update 在线检查更新 - Windows Server 2012 R2: Check online for updates from Microsoft Update via PowerShell 如何在Powershell脚本中将MS Web Deploy安装到Azure Windows Server 2012 R2 VM? - How do I install MS Web Deploy to an Azure Windows Server 2012 R2 VM in a powershell script? 使用Powershell Windows Server 2008 R2将用户导入本地 - Import users to local with powershell windows server 2008 r2 Windows 2012 R2中的Powershell 5.1 - Powershell 5.1 in Windows 2012 R2 如何使用 Powershell 为组中的用户分配自定义应用程序设置策略? - How to Assign a custom app setup policy to users in a group using Powershell? Windows Server AD 2022 - 使用 PowerShell 通过 GPO 将域用户添加到本地组“远程桌面用户” - Windows Server AD 2022 - Add a domain user to the local group "Remote Desktop Users" via GPO using PowerShell 为什么我在 Windows Server 2012 r2 上的 PowerShell ISE 中运行 Get-WindowsCapability 时出现错误? - Why do I get an error running Get-WindowsCapability in PowerShell ISE on Windows Server 2012 r2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM