tri_94 Posted October 15, 2019 Posted October 15, 2019 Hi there Using the following command Get-ADOrganizationalUnit -LDAPFilter '(gPLink=*{.........-.....-......-.....-..........}*)' I want to be able to define the GUID of the gpo via $GPOGUID = {.........-.....-......-.....-..........} However it doesnt seem to work for me. Script is below. Im creating it to be able to copy gpo links from one gpo to another. Thanks Nick # Command can be used to get GUID #Get-ADOrganizationalUnit -LDAPFilter '(gPLink=*)' #Enter Destination GPO $DestinationGPOName = "GPONAME" #Enter Guid '(gPLink=*{Enter GUID HERE}*)' $Info = Get-ADOrganizationalUnit -LDAPFilter '(gPLink=*{.........-.....-......-.....-..........}*)' #Export GPO Links to txt file - Path c:\notes\links.txt $Info.DistinguishedName > "c:\notes\links.txt" #Import data from path c:\notes\links.txt $List = Get-Content "c:\notes\links.txt" #Foreach entry in c:\notes\links.txt Foreach ($Link in $list) { #Add new link to GPO entered at the top New-GPLink -Name $DestinationGPOName -Target $Link }
HPlum78 Posted October 15, 2019 Posted October 15, 2019 (edited) $GPOGUID = '*{D16A8C8A-0C59-4371-8640-E99E8CCFB726}*' Get-ADOrganizationalUnit -LDAPFilter "(gPLink=$GPOGUID)" in fact $GPOGUID = '{D16A8C8A-0C59-4371-8640-E99E8CCFB726}' Get-ADOrganizationalUnit -LDAPFilter "(gPLink=*$($GPOGUID)*)" Edited October 15, 2019 by HPlum78 1
tri_94 Posted October 15, 2019 Author Posted October 15, 2019 Thats great. It works perfect. I'm sure i already tried but anyway it now working. Thanks again
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now