Configuring Group Policy Sites (and more) with Powershell

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 2 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
tryllzhuud
Posts: 7
Last visit: Tue Nov 09, 2021 5:30 am

Configuring Group Policy Sites (and more) with Powershell

Post by tryllzhuud »

Hi,

I’m working on Powershell for automation of a DC, I need to know 2 things.

How do I add sites into Group Policy Management (image below) with Powershell

https://i.ibb.co/DgWCsZG/1.png

https://i.ibb.co/fvRTdPw/4.png

https://i.ibb.co/5FTG4LQ/5.png

https://i.ibb.co/jkRxVfp/6.png

How do I edit Group policy Management Editor configurations with Powershell

https://i.ibb.co/9NgrRfQ/2.png

https://i.ibb.co/cgjC1gN/3.png

The ADReplicationSite command works for adding sites to the AD Sites and Services window, and there are no other commands to allow working in the GPO window.

Similarly the GPO related commands have nothing related to this as well (yes there are commands that allow the GPO to link to the site, which I have already done, but there are no commands to show the sites in GP window which is what Im looking for).

Thank You
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Configuring Group Policy Sites (and more) with Powershell

Post by jvierra »

Please review the Group Policy module documentation for instructions on how to use the module.

PowerShell does not automate the GP management applications; it edits AD directly. You will have to learn both the AD technical API and the GP technical API.

There is no simple way to directly edit individual policy rules. There are a few third-party GP policy editors in the PowerShell Gallery which you can review to find the one that suits your needs.

Do not attempt to automate editing of AD or GP without a full understanding of what is happening. You can crash AD easily via direct API edits.

The docs have examples of what can be done. You will have to understand what a GP is and how to use registry settings to manage GP policy rules and settings although the third-party tools can make some of this easier.

https://docs.microsoft.com/en-us/powers ... ver2019-ps
This topic is 2 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked