Powershell script to Copy GPO Links to multiple sites, domains, or OUs
- dismekeavaslay
- Aug 14, 2023
- 2 min read
You can use Group Policies to copy specific files and folders to user computers in the Active Directory domain. You can place files on the Desktop, in a particular user profile directory, or in any other folder on a local drive. With GPO, you can automatically copy and update various configuration files, INI files, app executables (EXEs), DLLs, or scripts from a shared repository. (adsbygoogle = window.adsbygoogle []).push();
Note that Group Policy Preferences do not allow you to copy an entire directory with all child subfolders and files. If you need to copy a folder with a large number of files, or you want the contents of the target user folders to always be updated when any file in the source is updated, you can make a simple logon script and run it through the GPO.
Powershell script to Copy GPO Links
As always when you are copying scripts from the internet make sure that you understand what the script will do before you run it. Test it in a lab before using it in production. Open up the GPOMigration.psm1 module file and skim through the code. Review the full help content for each function. You will learn more PowerShell and get ideas for your own scripts.
Here is the tweet from May 21st, 2022 once I figured it out:After some conversations about this fix, I wanted to look for something more wholistic. Something that would stop both double click, right click mount, and scripted mounting from powershell, etc. So I found this: which led me here:
To read an XML report in PowerShell you can use the typecast to XML by using [xml] in front of the variable which should make querying the content easier. The only part of the XML that I really want currently is the LinksTo, as this shows where the GPO is assigned. Once I had all this information I was then able to create the full script. I will put the script up on GitHub since it easier for people to copy the script file.
As mentioned earlier, using Group Policies we can place files in a user profile folder or any directory on a local drive. We can automatically copy or update different configuration files, INI files, EXE files, DLL libraries or scripts from a shared repository.
For instance to copy two files (app.exe and settings.xml) to the desktops of some Active Directory domain users, we can automate copying files to domain computers using GPO logon scripts (by xcopy, robocopy, etc.).
2ff7e9595c
Comments