<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Thomas Bouchereau's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/thbouche/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/thbouche/feed.xml</link>
    <description>A simple space on the internet where I can share information about AD and GPOs that can be useful to all.</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:47:46 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>AGPM 4.0 SP3 Hotfix Package 1</title>
      <link>https://docs.microsoft.com/archive/blogs/thbouche/agpm-4-0-sp3-hotfix-package-1</link>
      <pubDate>Tue, 05 Jan 2016 04:39:00 GMT</pubDate>
      <dc:creator><![CDATA[Thomas Bouchereau (PFE)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/thbouche/2016/01/05/agpm-4-0-sp3-hotfix-package-1/</guid>
      <description><![CDATA[&nbsp; If you have been using AGPM SP3 since it’s release you might have run into the issue where...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p> <p>If you have been using AGPM SP3 since it’s release you might have run into the issue where AGPM could not generate Difference reports for controlled GPOs.</p> <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/image_755CBD13.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/image_5F00_755CBD13.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/image_thumb_19F0DB49.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/image_5F00_thumb_5F00_19F0DB49.png" width="328" height="187" /></a></p> <p>A hotfix for this issue has been released during the holidays season.<br /><a href="https://support.microsoft.com/en-us/kb/3127165" target="_blank">HotFix Package for Microsoft Advanced Group Policy Management 4.0 SP3</a></p> <p>Once installed on the AGPM server you will be able to generate the Difference reports has usual.</p> <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/image_3BDC3DCD.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/image_5F00_3BDC3DCD.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/image_thumb_1D9186D7.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/image_5F00_thumb_5F00_1D9186D7.png" width="330" height="194" /></a></p>]]></content:encoded>
    </item>
    <item>
      <title>Checking AGPM GPOs managed with powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/thbouche/checking-agpm-gpos-managed-with-powershell</link>
      <pubDate>Thu, 15 Oct 2015 05:32:00 GMT</pubDate>
      <dc:creator><![CDATA[Thomas Bouchereau (PFE)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/thbouche/2015/10/15/checking-agpm-gpos-managed-with-powershell/</guid>
      <description><![CDATA[Hi all,
It&#39;s been a long time since I posted anything here. Basically life, baby and all that...]]></description>
      <content:encoded><![CDATA[<p>Hi all,</p>
<p>It&#39;s been a long time since I posted anything here. Basically life, baby and all that happened taking all of my free time. <br />That doesn&#39;t mean I have stopped working with GPOs and Powershell.</p>
<p>Recently a new version of AGPM has been released : AGPM 4.0 SP3: <a href="https://technet.microsoft.com/en-us/library/mt346469.aspx"><span style="font-family:Segoe UI;font-size:10pt;">https://technet.microsoft.com/en-us/library/mt346469.aspx</span></a><span style="color:black;font-family:Segoe UI;font-size:10pt;"> </span></p>
<p><span style="color:black;font-family:Segoe UI;font-size:10pt;">On top of now being compatible with Windows 10 client, it also introduce the first set of Powershell cmdlets for AGPM: <a href="https://technet.microsoft.com/en-us/library/mt445493.aspx">https://technet.microsoft.com/en-us/library/mt445493.aspx</a> </span></p>
<p><span style="color:black;font-family:Segoe UI;font-size:10pt;">I have been promoting AGPM to my clients for a while now.<br />One of the &quot;issue&quot; that was reported with AGPM by clients, was that it introduced an issue in GPMC. </span></p>
<p><span style="color:black;font-family:Segoe UI;font-size:10pt;"><br />What I mean is that after installing AGPM you have the add-in &quot;Change Control&quot; that appears in GPMC </span></p>
<p><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/101515_1236_CheckingAGP1.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/101515_5F00_1236_5F00_CheckingAGP1.png" /></p>
<p>This is where &quot;AGPM&quot; is and where you should now manage your GPOs.</p>
<p>But you can still edit the production GPOs through GPMC, mostly Domain admins.<br />There are ways to remove that right but it can be reversed (<a href="/b/askds/archive/2011/06/21/forcing-domain-admins-to-use-agpm-but-not-really.aspx"><span style="font-family:Segoe UI;font-size:10pt;">https://blogs.technet.com/b/askds/archive/2011/06/21/forcing-domain-admins-to-use-agpm-but-not-really.aspx</span></a><span style="color:black;font-family:Segoe UI;font-size:10pt;">)<br />So in the end only Education of your administrator will work. </span></p>
<p>This &quot;issue&quot; can introduce divergence between the version in production and the one in AGPM.<br />This could lead to settings in production being lost when a GPO that was modified in AGPM is deployed.</p>
<p>The script I am presenting you will help identify those GPOs that have been modified outside of AGPM and prevent possible loss of setting.</p>
<p>It is based on 2 powershell cmdlet:</p>
<p>Get-controlledGPO: New cmdlet provided with AGPM 4.0 SP3 that list all GPOs managed by AGPM. Meaning that a copy of the GPO is in the AGPM Archive.<br />Get-GPO: classic GPO cmdlet that list all GPOs in a domain.</p>
<p>Based on the different dates and version number provided by the cmdlets, we can now have an idea of the status of GPOs managed by AGPM.</p>
<p><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/101515_1236_CheckingAGP2.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/101515_5F00_1236_5F00_CheckingAGP2.png" /></p>
<p>Controlled: with a value of Yes or No will let you know if the GPO is controlled by AGPM.</p>
<p>Version status: Values can be</p>
<p>&quot;AGPM version in production&quot;: same GPO in production and in AGPM (all is good)<br />&nbsp;&nbsp;&nbsp;&nbsp;&quot;New AGPM version not in production&quot;: the GPO is being modified in AGPM. Next step would be to by deployed in production. So check the modification date to see if it is a recent change or a GPO that was not put in production.<br />&nbsp;&nbsp;&nbsp;&nbsp;&quot; Modified in GPMC&quot;: You need to check this GPO as it has been modified outside of AGPM.</p>
<p>This is a first version of the script and it has only been written to work on the current domain. I have not yet tested with an AGPM that contains multiple domains, even if this is not a recommended configuration it can be found.</p>
<p>As usual let me know your thoughts and suggestions on this script.</p>
<p>Script can be found <a href="https://gallery.technet.microsoft.com/Checking-AGPM-GPOs-managed-eb469e69">here</a></p>]]></content:encoded>
    </item>
    <item>
      <title>AGPM Quick Configuration Script</title>
      <link>https://docs.microsoft.com/archive/blogs/thbouche/agpm-quick-configuration-script</link>
      <pubDate>Mon, 23 Jun 2014 02:16:00 GMT</pubDate>
      <dc:creator><![CDATA[Thomas Bouchereau (PFE)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/thbouche/2014/06/23/agpm-quick-configuration-script/</guid>
      <description><![CDATA[It&rsquo;s been a while since I posted anything here, but I&rsquo;m back and I have a few things to...]]></description>
      <content:encoded><![CDATA[<p>It&rsquo;s been a while since I posted anything here, but I&rsquo;m back and I have a few things to share.</p>
<p>Today it&rsquo;s about AGPM (Advanced Group Policy Management).<br /> I&rsquo;m a not going to get into details on how AGPM works, there are plenty of other blogs about the subject.</p>
<p><br /> I regularly go onsite to clients to help them set up AGPM in their environment and when installing AGPM you always want to have this article in mind from the Ask Directory Services Team on how to set AGPM with least privilege (<a href="/b/askds/archive/2008/12/16/agpm-least-privilege-scenario.aspx">here</a>).<br /> After a few half dozen times, I started thinking about automating these tasks.</p>
<p>So here is a powershell script that I use to quickly prepare the environment for the installation of AGPM.</p>
<p>In details what it does is:</p>
<p>1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create an OU where all AGPM accounts and Groups will be stored</p>
<p>2)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create the AGPM service account with a never expiring password (you are prompted to manually enter that password)</p>
<p>3)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Add the AGPM service account to the groups &ldquo;Backup Operator&rdquo; and &ldquo;Group Policy Creator owners&rdquo;</p>
<p>4)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create the AGPM Full admin account (you are prompted to manually enter the password)</p>
<p>5)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create an &ldquo;AGPM_Admin&rdquo; group and add the AGPM Full admin account to it. This groups can then later be delegated the full admin role in AGPM</p>
<p>6)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create an &ldquo;AGPM_Approver&rdquo; group. This Group can later be delegated the Approver role in AGPM</p>
<p>7)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create an &ldquo;AGPM Editor&rdquo; group. This group can later be delegated the Editor role in AGPM</p>
<p>8)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create an &ldquo;AGPM Reviewer&rdquo; group. This group can later be delegated the Reviewer role in AGPM</p>
<p>9)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Give full control on all existing GPOs to the AGPM Service Account</p>
<p>10)&nbsp;&nbsp; Give the &ldquo;Read Gplink&rdquo; and &ldquo;Write gplink&rdquo; extended rights to the root of the OU structure to the AGPM Service account</p>
<p>However to be in line with the Least Privilege article, you will have to manually give Full control to the AGPM Archive folder and Temp folder to the AGPM service account on the AGPM server, once AGPM is installed.</p>
<p><br />You can download the script <a href="https://gallery.technet.microsoft.com/AGPM-Quick-Configuration-a7f42d46">here</a></p>
<p>I give this script as is and you can modify it as much as you want.<br /> &nbsp;There is no requirements for groups to install AGPM, as well as the OU to store the groups and users. This is just a habit I have.</p>
<p><br /> The main tasks you want to keep if you want to customize it are:</p>
<p>1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create the AGPM service account</p>
<p>2)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create the Full admin account (even this one is optional)</p>
<p>3)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Add the AGPM service account to the groups &ldquo;Backup Operator&rdquo; and &ldquo;Group Policy Creator Owners&rdquo;</p>
<p>4)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Give full control on all existing GPOs to the AGPM service account</p>
<p>5)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Give the &ldquo;Read Gplink&rdquo; and &ldquo;Write gplink&rdquo; extended rights to the root of the OU structure to the AGPM Service account</p>
<p>As usual let me know your inputs.<br /> <br /> Thomas</p>
<p></p>]]></content:encoded>
    </item>
    <item>
      <title>Group Policy Links Backup and Restore functions</title>
      <link>https://docs.microsoft.com/archive/blogs/thbouche/group-policy-links-backup-and-restore-functions</link>
      <pubDate>Thu, 20 Feb 2014 04:37:00 GMT</pubDate>
      <dc:creator><![CDATA[Thomas Bouchereau (PFE)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/thbouche/2014/02/20/group-policy-links-backup-and-restore-functions/</guid>
      <description><![CDATA[Updated on 2/20/2014:
restore-gplink function was updated to incorporate cases that were not...]]></description>
      <content:encoded><![CDATA[<div>
<p><strong>Updated on 2/20/2014:</strong></p>
<p><strong>restore-gplink function was updated to incorporate cases that were not included at first.</strong></p>
<strong>===================================</strong></div>
<div></div>
<div>Hi</div>
<div>A few months back, I put together a function that allowed me to collect the GPLinks information on targeted OUs and sites.<br /> In the<a href="/b/thbouche/archive/2013/10/11/get-gplink-function-v1-3.aspx"> post</a> it was also explained how you could run that function on an OU structure to create a global GPlink backup file.</div>
<div>Only I recently thought that I would be more useful to be able to target a GPO and backup the location of where it is linked.<br /> And of course once you have the backup you will want to be able to restore it.</div>
<div><strong><span style="text-decoration:underline;">Dependencies:</span></strong></div>
<div>Those new functions (at least the backup one) will need you to use the &ldquo;get-gplink&rdquo; function I have created.</div>
<div><br /> The main reason is the format that I have used to export information on the status of the links.</div>
<div><img width="551" height="245" id="108972" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108972/1/image001.jpg" /></div>
<div>As you can see, I return the values as &ldquo;yes&rdquo; and &ldquo;no&rdquo;.</div>
<div>Using the get-gpinheritance it returns &ldquo;True&rdquo; and &ldquo;False&rdquo;</div>
<div><img width="686" height="236" id="108973" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108973/1/image002.jpg" /></div>
<div>The problem is that the cmdlet &ldquo;new-gplink&rdquo; or &ldquo;set-gplink&rdquo; , when it comes to the switches, expects a value of &ldquo;yes&rdquo; and &ldquo;no&rdquo;</div>
<div><img width="587" height="113" id="108974" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108974/1/image003.jpg" /></div>
<div>So because I do not want to have to manipulate those ouputs, I simply use my function.<br /> By the way, this was why I set the output of my function to use &ldquo;yes&rdquo; and &ldquo;no&rdquo; from the start.</div>
<div><strong><span style="text-decoration:underline;">Backup-gplink function</span></strong></div>
<div>The best way I know of getting where a GPO is linked (besides using GPMC) is to look at a GPO report.<br /> With Powershell you can get that report with a simple line:</div>
<div><img width="486" height="23" id="108975" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108975/1/image004.jpg" /></div>
<div>What we are interested in is the &ldquo;links&rdquo; part of the report as it contains the information we are looking for. Be careful as it only includes the links of the GPO in its own domain.</div>
<div><img width="1052" height="93" id="108976" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108976/1/image005.jpg" /></div>
<div>Now HTML is fine for viewing but not for parsing.</div>
<div><br /> We can change the output of the get-gpreport to export in xml and we can even load that output into a variable.</div>
<div><img width="394" height="21" id="108977" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108977/1/image006.jpg" /></div>
<div>The [xml] at the beginning of the line is to declare the type of the variable $xml. Basically we have declared that the content of the variable is in xml format.</div>
<div>Now what can we do with that variable&hellip; Well navigate its content of course.</div>
<div><img width="820" height="94" id="108978" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108978/1/image007.jpg" /></div>
<div>We now have a format that we can manipulate and we have almost all the information we need, we are only missing the link order&hellip; and that is a shame.<br /> That is where we need to use the get-gpink to collect that information.<br /> So out of that report I am only interested in the SOMPath that will contain all the locations where the GPO is linked.</div>
<div>Once you have registered the functions by &ldquo;dotnetting&rdquo; the script I have provide, you will be able to use the function &ldquo;Backup-gplink&rdquo;.</div>
<div><img width="599" height="26" id="108979" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108979/1/image008.jpg" /></div>
<div>The function has two parameters:</div>
<div><strong>Gponame:</strong> the name of the GPO you want to backup the gplinks<br /> <strong>path:</strong> path to where you want to save the backup file. (in this example the variable $pwd indicate the location of my prompt &ldquo;C:\Users\Administrator\Documents&rdquo; )</div>
<div>The output is a simple csv file, name &lt;gponame&gt;_gplinksbackup.csv that you can later see and manipulate.</div>
<div><img width="1020" height="149" id="108980" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108980/1/image009.jpg" /></div>
<div><strong><span style="text-decoration:underline;">Restore-gplink</span></strong></div>
<div>Once you have that backup, you might want to use it to restore a gpo gplinks.<br /> That function is very simple and has only one input and a switch</div>
<div><img width="343" height="15" id="108981" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108981/1/image010.jpg" /></div>
<div>It will consume the content of the CSV file and use either the cmdlet &ldquo;new-gplink&rdquo; to link the GPO to the location where they were previously linked or if already linked &ldquo;set-gplink&rdquo; to re-apply<br /> the configuration that was in the backup (in case it was changed).</div>
<div>So you have your GPO linked:</div>
<div><img width="605" height="166" id="108982" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108982/1/image011.jpg" /></div>
<div>After an error (human or else..) the links are gone:</div>
<div><img width="384" height="141" id="108983" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/108983/1/image012.jpg" /></div>
<div>Run the above command</div>
<div><img width="849" height="202" id="109105" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/109105/1/image002.jpg" /></div>
<div>The links will be restored but with a disabled state. The idea is to prevent restoring a GPO link that would impact the production.<br /> You will manually have to enable the link again to make it effective.</div>
<div>The script will change the link order from the one in the backup if there is not the same number of links on the SOM or if the retsored gplink is the only one and add an order different then 1 in the backup.</div>
<div>If the GPO is still linked at the same location the script will not by default, chnage tha value of the link</div>
<div><img width="623" height="112" id="109110" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/109110/1/capture.jpg" /></div>
<div>However if you want to force the values that are in the backup file, you can use the -force switch:</div>
<div><img width="712" height="340" id="109111" alt=" " src="https://i1.gallery.technet.s-msft.com/group-policy-links-backup-a46df1d3/image/file/109111/1/capture2.jpg" /></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><strong><span style="text-decoration:underline;">Backupgpofull</span></strong></div>
<div>Here is a quick and dirty way of planning a daily backup of your GPOs with their GPLinks. This script will remove content that is older than a day and do a backup of the GPO<br /> and the GPOs Links.</div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:blue;">get-childitem</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;"> <span style="color:navy;">-Path</span> <span style="color:orangered;">$pwd</span><span style="color:blueviolet;">\bck</span> <span style="color:darkgray;">|</span> <span style="color:blue;">where-object</span> {<span style="color:orangered;">$_</span><span style="color:darkgray;">.</span>LastAccessTime <span style="color:darkgray;">-le</span> (<span style="color:blue;">get-date</span>)<span style="color:darkgray;">.</span>adddays(<span style="color:purple;">-1</span>)} <span style="color:darkgray;">|</span><span style="color:blue;">foreach</span> { <span style="color:blue;"> Remove-Item</span> <span style="color:navy;">-Path</span> <span style="color:orangered;"> $pwd</span><span style="color:blueviolet;">\bck\</span><span style="color:orangered;">$_</span> <span style="color:navy;">-force</span>&nbsp; <span style="color:navy;">-Recurse</span>}</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:blue;">get-gpo</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;"> <span style="color:navy;">-all</span> <span style="color:darkgray;">|</span> <span style="color:blue;"> foreach</span> {</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:blue;">Backup-GPO</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;"> <span style="color:navy;">-name</span> <span style="color:orangered;">$_</span><span style="color:darkgray;">.</span>displayname <span style="color:navy;">-Path</span> <span style="color:orangered;">$pwd</span><span style="color:blueviolet;">\bck</span></span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:blue;">backup-gplink</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;"> <span style="color:navy;">-gponame</span> <span style="color:orangered;">$_</span><span style="color:darkgray;">.</span>displayname <span style="color:navy;">-path</span> <span style="color:orangered;">$pwd</span><span style="color:blueviolet;">\bck</span></span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">} </span></div>
<div>&nbsp;</div>
<div><strong><span style="text-decoration:underline;">Restoregpofull</span></strong></div>
<div>Based on that output you could use the following code to restore your backup and their gplinks</div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:orangered;">$directories</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:darkgray;">=</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:blue;">Get-ChildItem</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;"> <span style="color:navy;">-Path</span> <span style="color:orangered;">$pwd</span><span style="color:blueviolet;">\bck</span> <span style="color:navy;">-Directory</span></span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:orangered;">$files</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:darkgray;">=</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;color:blue;">Get-ChildItem</span><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;"> <span style="color:navy;">-Path</span> <span style="color:orangered;">$pwd</span><span style="color:blueviolet;">\bck</span> <span style="color:navy;">-File</span></span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;<span style="color:darkblue;">foreach</span> (<span style="color:orangered;">$d</span> <span style="color:darkblue;">in</span> <span style="color:orangered;">$directories</span>)</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;{</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;<span style="color:blue;">Restore-GPO</span> <span style="color:navy;">-BackupId</span> <span style="color:orangered;">$d</span><span style="color:darkgray;">.</span>name <span style="color:navy;">-Path</span> <span style="color:orangered;">$pwd</span><span style="color:blueviolet;">\bck</span></span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;}</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;<span style="color:darkblue;">foreach</span> (<span style="color:orangered;">$f</span> <span style="color:darkblue;">in</span> <span style="color:orangered;">$files</span>)</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;&nbsp;&nbsp; {</span></div>
<div style="margin-bottom:.0001pt;background:white;"><span style="font-size:9.0pt;font-family:&#39;Lucida Console&#39;;">&nbsp;&nbsp;&nbsp; <span style="color:blue;"> restore-gplink</span> <span style="color:navy;">-path</span> <span style="color:orangered;"> $pwd</span><span style="color:blueviolet;">\bck\</span>$(<span style="color:orangered;">$f</span><span style="color:darkgray;">.</span>Name)</span></div>
<div>&nbsp;</div>
<div>As usual hope you find this useful in your daily work and please give we feedback on this.</div>
<div></div>
<div>Script can be found <a href="https://gallery.technet.microsoft.com/Group-Policy-Links-Backup-a46df1d3">here</a></div>]]></content:encoded>
    </item>
    <item>
      <title>Group Policy processing events collection with Powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/thbouche/group-policy-processing-events-collection-with-powershell</link>
      <pubDate>Wed, 30 Oct 2013 07:19:00 GMT</pubDate>
      <dc:creator><![CDATA[Thomas Bouchereau (PFE)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/thbouche/2013/10/30/group-policy-processing-events-collection-with-powershell/</guid>
      <description><![CDATA[Updated:&nbsp;02/05/2014&nbsp;
The script has been optimized thanks for my colleague Pierre...]]></description>
      <content:encoded><![CDATA[<p><strong><span style="text-decoration:underline;">Updated:&nbsp;02/05/2014</span>&nbsp;</strong></p>
<p><strong>The script has been optimized thanks for my colleague Pierre Audonnet.</strong><br /><strong>You can also now export to csv and html format.</strong></p>
<p><strong>=============================================================</strong></p>
<p>When troubleshooting GPO processing we have a lot of tools available to us.<br />Since Windows Vista, we especially have a new Event Log that register all events related to GPO processing.</p>
<p><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/1323.103013_1457_GroupPolicy1.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/1323.103013_5F00_1457_5F00_GroupPolicy1.png" /></p>
<p>One &quot;new&quot; feature is that each GPO event is assigned an Activity ID that is unique for a GPO processing.</p>
<p><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/5852.103013_1457_GroupPolicy2.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/5852.103013_5F00_1457_5F00_GroupPolicy2.png" /></p>
<p>Tools such as GPlogview can use that Activity ID to sort large event logs and focus on a specific GPO processing.</p>
<p>You can also create a custom event log view to sort them using the following &quot;Query&quot;:</p>
<p><em>&lt;QueryList&gt;&lt;Query Id=&quot;0&quot; Path=&quot;Application&quot;&gt;&lt;Select Path=&quot;Microsoft-Windows-GroupPolicy/Operational&quot;&gt;*[System/Correlation/@ActivityID=&#39;{INSERT ACTIVITY ID HERE}&#39;]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt; </em></p>
<p><span style="font-size:9pt;">More details in the following article: https://technet.microsoft.com/en-us/library/cc749336(v=WS.10).aspx<em> </em></span></p>
<p>Problems with those tools are that:</p>
<ol>
<li>You need to have GPLogView already installed on a computer to collect locally or remotely. You also need to know the Activity ID corresponding to the GPO processing you want to analyze.</li>
<li>If using the Custom Log view, you need to either export the log on your computer or create the custom log view on the computer you want to analyse.</li>
</ol>
<p>What about if you could list the lasted Activity IDs log on a computer and then sort only those events corresponding to these Activity ID.</p>
<p>That was the starting point of this little project.</p>
<p><span style="text-decoration:underline;"><strong>Getgpoprocessing.ps1 </strong></span></p>
<p>An Activity ID is assigned at each new GPO processing. As you might know there is eight events that will trigger a new GPO processing:</p>
<ul>
<li>Computer Boot</li>
<li>User Logon</li>
<li>Computer background refresh</li>
<li>User background refresh</li>
<li>Computer Network Change</li>
<li>User Network Change</li>
<li>Computer Manual Update</li>
<li>User Manual Update</li>
</ul>
<p>Each of those event is logged in the group policy event log with a specific event ID:</p>
<ul>
<li>Computer Boot: event ID 4000</li>
<li>User Logon: event ID 4001</li>
<li>Computer Background Refresh: event ID 4006</li>
<li>User Background Refresh: event ID 4007</li>
<li>Computer Network Change: event 4002</li>
<li>User Network Change: event 4003</li>
<li>Computer Manual Update: event 4004</li>
<li>
<div>User Manual Update: event 4005</div>
<p>&nbsp;</p>
</li>
</ul>
<p>To access the Group Policy event log, you can use the powershell cmdlet: get-winevent</p>
<p><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/5282.103013_1457_GroupPolicy3.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/5282.103013_5F00_1457_5F00_GroupPolicy3.png" /></p>
<p>So what my script does is simple:</p>
<ol>
<li>Collect the group policy events over a period of hours that you specify on a local or remote computer</li>
<li>Display the events corresponding to a new GPO processing</li>
<li>Have you select the one you are interested in and gives you all corresponding events base on the Activity ID.</li>
</ol>
<p>Here is an example:</p>
<p><em>Getgpoprocessing &ndash;hours 2 </em></p>
<p><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/1300.103013_1457_GroupPolicy4.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/1300.103013_5F00_1457_5F00_GroupPolicy4.png" /></p>
<p>Here you can see that we have a periodic policy refresh for the computer every 5 minutes. This is normal as it is collected on a DC.</p>
<p>The same command to collect on a remote member server:</p>
<p><em>Getgpoprocessing &ndash;hours 2 &ndash;computer 2012MS </em></p>
<p><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/4064.103013_1457_GroupPolicy5.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/4064.103013_5F00_1457_5F00_GroupPolicy5.png" /><em> </em></p>
<p>Once you have the &quot;Starting&quot; events, all you need is to enter the number of the one you want to review.</p>
<p><br />Following the collection on member server 2012MS, I will select 1 to review the background User GPO processing for user &quot;Administrator&quot; with Activity ID {7B27C738-6A05-40A2-8187-A0D97111182D}</p>
<p><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/5670.103013_1457_GroupPolicy6.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/5670.103013_5F00_1457_5F00_GroupPolicy6.png" /></p>
<p>I now have the list of events from the Group Policy event log of member server 2012MS, with Activity ID {7B27C738-6A05-40A2-8187-A0D97111182D}.<br />The script only display the LevelDisplayName (Information, Warning, Error) and the message in the event.</p>
<p>You can also chosse to&nbsp;export the results&nbsp;to csv or html or both by adding the -csv $true or -html $true switches</p>
<p><img alt=" " /></p>
<p><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/0272.103013_1457_GroupPolicy8.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/0272.103013_5F00_1457_5F00_GroupPolicy8.png" /></p>
<p>The file name format are:</p>
<p>&lt;computername&gt;-&lt;ActivityID&gt;-gpoprocessing.csv</p>
<p>&lt;computername&gt;-&lt;ActivityID&gt;-gpoprocessing.html</p>
<p>If you do not specify a computer, meaning you run the script locally the &lt;computername&gt; is replaced by &quot;LocalHost&quot;</p>
<p><span><strong><span style="text-decoration:underline;">Requirements:</span></strong></span></p>
<p>I order to use this script, you will need to have access to the Event logs, locally or remotely.</p>
<p>As usual you can find the script <a href="https://gallery.technet.microsoft.com/Group-Policy-processing-134c747b">here</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Get-GPlink function V1.3</title>
      <link>https://docs.microsoft.com/archive/blogs/thbouche/get-gplink-function-v1-3</link>
      <pubDate>Fri, 11 Oct 2013 05:45:00 GMT</pubDate>
      <dc:creator><![CDATA[Thomas Bouchereau (PFE)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/thbouche/2013/10/11/get-gplink-function-v1-3/</guid>
      <description><![CDATA[Hi all
As promised I return to you with an updated version of my function get-gplink.Here is the...]]></description>
      <content:encoded><![CDATA[<p>Hi all</p>
<p>As promised I return to you with an updated version of my function get-gplink.<br />Here is the list of what is changed from version 1.0:</p>
<p>New set of switches:</p>
<p style="margin-left: 36pt;">-path: DN of the object you want to get the gplink information<br />-site: Just to indicate that you are running the command against a site object. This will change the internal process to target the Configuration partition.<br />- server: if you are running the command from a domain that is different from the target domain of your command, you will need to specify a DC of that target domain</p>
<p>Compatibility with .NET 3.5:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;Turns out that version 1.0 was using some code that only .NET4 could handle.</p>
<p>New information returned:</p>
<p style="margin-left: 36pt;">If you recall version 1.0 could not return information about a GPO originating from a different domain and was returned the same as an "Orphaned Gplink".<br />Version 1.3 can now get that information and also return the originating domain of the GPO.<br />This means that anything that is reported as "Orphaned Gplink" is now a real orphaned.</p>
<p>To register that new version of get-gplink just run the command ". .\get-gplink_v1.3.ps1"<br />It will replace the get-gplink you might have been using.</p>
<p>Check the get-help of the function. I have changed a bit the output. Instead of "path", you get "Target" and "GPOGUID" has been changed into "gpoid" and"GPOName" to "DisplayName".This is to aligned with the "set-gplink" and "new-gplink" cmdlets.</p>
<ul>
<li>Get Gplink on the OU "domain controllers" of contoso.com</li>
</ul>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/8053.101113_1245_GetGPlinkfu1.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/8053.101113_5F00_1245_5F00_GetGPlinkfu1.png" alt="" /></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/8468.101113_1245_GetGPlinkfu2.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/8468.101113_5F00_1245_5F00_GetGPlinkfu2.png" alt="" /></p>
<ul>
<li>Get gplink on the OU "domain controllers" of domain child.contoso.com</li>
</ul>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/0447.101113_1245_GetGPlinkfu3.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/0447.101113_5F00_1245_5F00_GetGPlinkfu3.png" alt="" /></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/3107.101113_1245_GetGPlinkfu4.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/3107.101113_5F00_1245_5F00_GetGPlinkfu4.png" alt="" /></p>
<ul>
<li>Get gplink on Site "Site1"</li>
</ul>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/5756.101113_1245_GetGPlinkfu5.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/5756.101113_5F00_1245_5F00_GetGPlinkfu5.png" alt="" /></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/2548.101113_1245_GetGPlinkfu6.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/2548.101113_5F00_1245_5F00_GetGPlinkfu6.png" alt="" /></p>
<p><span style="text-decoration: underline;">Bonus: </span></p>
<p>So, while I was working on improving my code, I spent time looking into what the cmdlet "get-gpinheritance" could do.. and guess what, it can actually do most of what my code does.</p>
<p>I say most of because while it is on average faster than my code (I could probably improve that), it does not give all the information I found relevant to gplinks.</p>
<p>Here is an example:</p>
<p>I have GPOs linked at the OU "Domain Controllers"</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/0804.101113_1245_GetGPlinkfu7.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/0804.101113_5F00_1245_5F00_GetGPlinkfu7.png" alt="" /></p>
<p>As you can see one of them is an Orphaned Gplink and the others are normal GPos.</p>
<p>The command you can use with get-gpinheritance is this one:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/7343.101113_1245_GetGPlinkfu8.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/7343.101113_5F00_1245_5F00_GetGPlinkfu8.png" alt="" /></p>
<p>And here is the result:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/8838.101113_1245_GetGPlinkfu9.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/8838.101113_5F00_1245_5F00_GetGPlinkfu9.png" alt="" /></p>
<p>As you can see, we have the order, the Enabled, Enforced, GPOID and name. As expected we have one GPO with no name as it is an Orphaned Gplink</p>
<p>Now here is what you get when you use my code:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/7183.101113_1245_GetGPlinkfu10.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/7183.101113_5F00_1245_5F00_GetGPlinkfu10.png" alt="" /></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/7608.101113_1245_GetGPlinkfu11.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/7608.101113_5F00_1245_5F00_GetGPlinkfu11.png" alt="" /></p>
<p>You still get the same order, Enforced and Enabled status, but you also get more information:</p>
<ol style="margin-left: 54pt;">
<li>Instead of a blank name you get "orphaned-gplink". A bit more explicite than a "blank" space</li>
<li>If you look closely at the "GHC_U_Disabled_GPO_Test_1" GPO, you will noticed that it is not a GPO from "contoso.com" but from the domain "child.contoso.com"</li>
</ol>
<p>The fact that I don't have those information with the get-gpinheritance makes it hard to use that command in some cases.<br />As an example, I would have found it very useful to help me backup that order information and backup the GPO at the same time, but because I do not have the "originating" domain, I cannot use the output to pipe it to a "backup-gpo" cmdlet.</p>
<p>Also if you look at the command "set-gplink", it can manage linking GPOs from a remote domain by using the switch "domain". The output my code provides can simply be re-used entirely by the "set-gplink".</p>
<p>&nbsp;</p>
<p>One other thing that you can get with the get-gpinheritance cmdlet is the gpo inheritance (make sense no?)</p>
<p>So the almost same command</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/8863.101113_1245_GetGPlinkfu12.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/8863.101113_5F00_1245_5F00_GetGPlinkfu12.png" alt="" /></p>
<p>will give you this</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/1263.101113_1245_GetGPlinkfu13.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/1263.101113_5F00_1245_5F00_GetGPlinkfu13.png" alt="" /></p>
<p>I have not implemented that in my code and probably won't.</p>
<p>However the get-inheritance cmdlet does not work on the Configuration partition and will not report Site linked GPOs.</p>
<p>&nbsp;</p>
<p><strong><span style="text-decoration: underline;">Conclusion:</span></strong></p>
<p>Instead of a simple update to my code, this time I will provide you with 2 bits of code:</p>
<p><span style="text-decoration: underline;"><strong>Get-gplink_V1.3.ps1: </strong></span></p>
<p>My code that gives a bit more information on the GPO links.</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>Get-gplink_SD.ps1 (SD as in single domain): </strong></span></p>
<p>A much simpler version of the function that is in fact derived from the get-gpinheritance</p>
<p>&nbsp;</p>
<p>You can find them <a href="https://gallery.technet.microsoft.com/Get-GPlink-Function-V13-b31253b4">here</a></p>
<pre>&nbsp;</pre>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>DFSR-SYSVOL Authoritative / Non-Authoritative Restore Powershell Functions</title>
      <link>https://docs.microsoft.com/archive/blogs/thbouche/dfsr-sysvol-authoritative-non-authoritative-restore-powershell-functions</link>
      <pubDate>Wed, 28 Aug 2013 05:19:00 GMT</pubDate>
      <dc:creator><![CDATA[Thomas Bouchereau (PFE)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/thbouche/2013/08/28/dfsr-sysvol-authoritative-non-authoritative-restore-powershell-functions/</guid>
      <description><![CDATA[Hi folks,
For this new post we are going to talk about DFSR replication SYSVOL restore.You might be...]]></description>
      <content:encoded><![CDATA[<p>Hi folks,</p>
<p>For this new post we are going to talk about DFSR replication SYSVOL restore.<br />You might be familiar with the following KB that explains the process of doing "D4/D2" like restore for SYSVOL when replicated over DFSR : <a href="https://support.microsoft.com/kb/2218556">https://support.microsoft.com/kb/2218556</a></p>
<p>Basically instead of having to configure registry keys like with FRS, you now need to change AD attributes to trigger either non-authoritative or authoritative restore of SYSVOL.</p>
<p>The attributes belong to the following object (one for each DC replication SYSVOL)</p>
<p><span style="color: #333333; font-family: Segoe UI; font-size: 10pt;">CN=SYSVOL Subscription,CN=Domain System Volume,CN=DFSR-LocalSettings,CN=<em>&lt;the server name&gt;</em>,OU=Domain Controllers,DC=<em>&lt;domain&gt; </em></span></p>
<p><span style="color: #333333; font-family: Segoe UI; font-size: 10pt;">They are <em>msdfsr-Enabled</em> and <em>msdfsr-options</em></span></p>
<p>The above KB recommend ADSIEDIT.MSC to modify those values and its fine if you have a small number of DCs to manage.</p>
<p>But being a proper AD admin, even 3 DCs is a large number for me.. and especially if you happen to have to do that procedure on Windows 2008R2 Core..during a disaster recovery procedure&hellip; No don't look around ADSIEDIT is not there&hellip;</p>
<p>It's from that experience that I decided to create some new powershell functions to help me ( and now you too) with this kind of situation.</p>
<p>So what are those functions?</p>
<p>There are 3 of them:</p>
<ul>
<li><strong>Get-SysvolDFSRconf </strong></li>
</ul>
<p>Pretty straight forward, it will simply give you the values of the attributes "msdfsr-Enabled" and "msdfsr-options" on the server you will specify<br /><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/8546.082813_1219_DFSRSYSVOLA1.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/8546.082813_5F00_1219_5F00_DFSRSYSVOLA1.png" alt="" /></p>
<ul>
<li><strong>Set-nonauthDFSRsysvol: </strong></li>
</ul>
<p>This function will allow you to set the values for the attribute msdfsr-Enable like explained in the chapter "How to perform a non-authoritative synchronization of DFSR Replicated SYSVOL"</p>
<p>There is a switch called "step" that can take the values 1 or 2.</p>
<p>The first command you need to run is:</p>
<p><em>Set-nonauthDFSRSysvol &ndash;server &lt;servername&gt; -step 1 </em></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/8867.082813_1219_DFSRSYSVOLA2.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/8867.082813_5F00_1219_5F00_DFSRSYSVOLA2.png" alt="" /></p>
<p>It will set the attribute of the specified server to FALSE (Step 1 of the KB procedure)</p>
<p>The second command you will have to run is:</p>
<p><em>Set-nonauthDFSRSysvol &ndash;server &lt;servername&gt; -step 2 </em></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/6712.082813_1219_DFSRSYSVOLA3.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/6712.082813_5F00_1219_5F00_DFSRSYSVOLA3.png" alt="" /></p>
<p>It will set the attribute of the specified server to TRUE (Step 5 of the KB procedure)</p>
<p>I have not integrated the DFSRDIAG POLLAD in the function as I wanted to keep things separated.<br />If you want to run it on a remote server you can use the following command:</p>
<p><em>Dfsrdiag pollad /member:DOMAIN\servername </em></p>
<p>&nbsp;</p>
<p>You can easily combine that function with a foreach loop that will contain all the DC you want to set as non-authoritative in the case of a global SYSVOL restore (step 11 of the chapter How to perform a authoritative synchronization of DFSR Replicated SYSVOL")</p>
<p>&nbsp;</p>
<ul>
<li><strong>Set-authDFSRSysvol: </strong></li>
</ul>
<p>This function will allow you to set the values for the attribute msdfsr-Enable and msdfsr-Options like explained in the chapter "How to perform a authoritative synchronization of DFSR Replicated SYSVOL"</p>
<p>There is a switch called "step" that can take the values 1 or 2.</p>
<p>The first command you need to run is:</p>
<p><em>Set-authDFSRSysvol &ndash;server &lt;servername&gt; -step 1 </em></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/8484.082813_1219_DFSRSYSVOLA4.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/8484.082813_5F00_1219_5F00_DFSRSYSVOLA4.png" alt="" /></p>
<p>It will set the attribute msdfsr-Enabled of the specified server to FALSE and the attribute msdfsr-options to 1 (Step 1 of the KB procedure)</p>
<p>The second command you will have to run is:</p>
<p><em>Set-authDFSRSysvol &ndash;server &lt;servername&gt; -step 2 </em></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/5661.082813_1219_DFSRSYSVOLA5.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/5661.082813_5F00_1219_5F00_DFSRSYSVOLA5.png" alt="" /></p>
<p>It will set the attribute msdfsr-Enabled of the specified server to TRUE (Step 6 of the KB procedure)</p>
<p>I have not integrated the DFSRDIAG POLLAD in the function as I wanted to keep things separated.<br />If you want to run it on a remote server you can use the following command:</p>
<p><em>Dfsrdiag pollad /member:DOMAIN\servername</em></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>You can download the PS script with the functions <a href="https://gallery.technet.microsoft.com/DFSR-SYSVOL-Authoritative-0adb6e19">here</a>.<br />You will need to "dot" it to register the functions in your environment.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/7343.082813_1219_DFSRSYSVOLA6.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/7343.082813_5F00_1219_5F00_DFSRSYSVOLA6.png" alt="" /></p>
<p>Hope you find those useful in any of your SYSVOL restore operations and please give me feedback.</p>]]></content:encoded>
    </item>
    <item>
      <title>Get-GpLink function and GpLink backup</title>
      <link>https://docs.microsoft.com/archive/blogs/thbouche/get-gplink-function-and-gplink-backup</link>
      <pubDate>Wed, 10 Jul 2013 08:21:00 GMT</pubDate>
      <dc:creator><![CDATA[Thomas Bouchereau (PFE)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/thbouche/2013/07/10/get-gplink-function-and-gplink-backup/</guid>
      <description><![CDATA[Hi all, 
Who hasn't been dreaming of a get-gplink cmdlet? How would it be so simple to run a...]]></description>
      <content:encoded><![CDATA[<p><span style="color: black; font-family: Arial; font-size: 9pt;">Hi all, </span></p>
<p><span style="color: black; font-family: Arial; font-size: 9pt;">Who hasn't been dreaming of a get-gplink cmdlet? How would it be so simple to run a command and get the list of GPOs links to a site, OU or domain DN? </span></p>
<p><span style="color: black; font-family: Arial; font-size: 9pt;">We could be doing so much with a simple "get-gplink".<br /><br />I recently was at a client where I was performing remediation following a Group Policy Health I did a year ago and where the client had not time to do it himself.<br />When I left, 12 month ago, I gave him a list of the GPOs that were linked to its domain and the state of the links. But I wasn't able to do it now, as it was done using the Group Policy Health Check tool.<br /><br />So I took upon myself to create the missing "get-glink" and I am now happy to share it with you. </span></p>
<p><span style="color: black; font-family: Arial; font-size: 9pt;">I have built it so that it produces objects that can be used by the existing cmdlets related to gplink: </span></p>
<ul style="margin-left: 42pt;">
<li><span style="color: black; font-family: Arial; font-size: 9pt;">new-gplink </span></li>
<li><span style="color: black; font-family: Arial; font-size: 9pt;">set-gplink </span></li>
<li><span style="color: black; font-family: Arial; font-size: 9pt;">remove-gplink </span></li>
</ul>
<p><span style="color: black; font-family: Arial; font-size: 9pt;">In order to use it, you first have to register it to your environment. You can do this by simply executing the script with no parameter <strong><em>.\get-gplink.ps1</em></strong> </span></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/1588.071013_1521_GetGpLinkcm1.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/1588.071013_5F00_1521_5F00_GetGpLinkcm1.png" alt="" /></p>
<p><span style="color: black; font-family: Arial; font-size: 9pt;">Run the command <strong><em>dir function:\</em></strong> and verify that get-gplink is registed </span></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/2664.071013_1521_GetGpLinkcm2.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/2664.071013_5F00_1521_5F00_GetGpLinkcm2.png" alt="" /></p>
<p>&nbsp;</p>
<p><span style="color: black; font-family: Arial; font-size: 9pt; text-decoration: underline;"><strong>Listing link GPO on an object: </strong></span></p>
<p><span style="color: black; font-family: Arial; font-size: 9pt;">Running the command <strong><em>get-help get-gplink &ndash;detailed</em></strong> will give you details on how to use the command. </span></p>
<p><span style="color: black; font-family: Arial; font-size: 9pt;">Here is what an output looks like: </span></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/1513.071013_1521_GetGpLinkcm3.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/1513.071013_5F00_1521_5F00_GetGpLinkcm3.png" alt="" /></p>
<p><span style="color: black; font-family: Arial; font-size: 9pt;">The same one returned in a table format: </span></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/6327.071013_1521_GetGpLinkcm4.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/6327.071013_5F00_1521_5F00_GetGpLinkcm4.png" alt="" /></p>
<p>&nbsp;</p>
<p><em>Path: returns the DN of the object you run the command against<br />GPOGUID: returns the GUID of the GPO linked<br />GPOName: returns the friendly name of the GPO<br />Enforced: Returns whether the GPO link is enforce or not<br />Enabled: returns whether the GPO link is enabled or not<br />Order: return the link order </em></p>
<p>If the GPOGUID cannot be found in the domain, the GPO name is replaced by "Orphaned GPLink or External GPO". This version of get-gplink does not verify the GUID in other domains of the forest. This will be for a future version. So a unknow GUID can be either an "External GPO" or an "Orphaned GPLINK"</p>
<p><br />An Orphaned GPLINK is a gplink that is pointing to a missing GPC (group policy container).</p>
<p>This is how it looks like in GPMC:<br /><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/5153.071013_1521_GetGpLinkcm5.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/5153.071013_5F00_1521_5F00_GetGpLinkcm5.png" alt="" /></p>
<p><span style="text-decoration: underline;"><strong>Exporting to CSV: </strong></span></p>
<p>Now the nice part about it is that you can simply export the results to a CSV file:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/8473.071013_1521_GetGpLinkcm6.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/8473.071013_5F00_1521_5F00_GetGpLinkcm6.png" alt="" /></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/0081.071013_1521_GetGpLinkcm7.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/0081.071013_5F00_1521_5F00_GetGpLinkcm7.png" alt="" /></p>
<p>What could you then do with that CSV file&hellip;</p>
<p>How about restoring deleted gplinks?</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>Restoring deleted links and link order: </strong></span></p>
<p>This is what I have exported in my csv:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/0827.071013_1521_GetGpLinkcm8.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/0827.071013_5F00_1521_5F00_GetGpLinkcm8.png" alt="" /></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/4456.071013_1521_GetGpLinkcm9.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/4456.071013_5F00_1521_5F00_GetGpLinkcm9.png" alt="" /></p>
<p>I now delete my links:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/0743.071013_1521_GetGpLinkcm10.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/0743.071013_5F00_1521_5F00_GetGpLinkcm10.png" alt="" /></p>
<p>Since I exported the links in the csv file, I can simply run the following command to restore them:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/7711.071013_1521_GetGpLinkcm11.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/7711.071013_5F00_1521_5F00_GetGpLinkcm11.png" alt="" /></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/0285.071013_1521_GetGpLinkcm12.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/0285.071013_5F00_1521_5F00_GetGpLinkcm12.png" alt="" /></p>
<p>My links have been restored in the proper order and with the proper options:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/2772.071013_1521_GetGpLinkcm13.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/2772.071013_5F00_1521_5F00_GetGpLinkcm13.png" alt="" /></p>
<p>&nbsp;</p>
<p>And now the "plat de r&eacute;sistance"&hellip;</p>
<p><span style="text-decoration: underline;"><strong>Group Policy Disaster Recovery: </strong></span></p>
<p>You got it, this export is actually also a backup of sort.</p>
<p>So with some little PS scripting here is how on top of doing a backup of all you domain gpo, you can do the same with your GPO links.</p>
<p>I won't explain how to use <em>backup-gpo</em> and <em>restore-gpo </em>to backup and restored GPOs in your domain. But simply give you the command that you can add now to be able to simply restore those links:</p>
<p><em>Get-adobject &ndash;filter {(objectclass &ndash;eq "domaindns") &ndash;or (objectclass &ndash;eq "organizationalunit")} | foreach {get-gplink &ndash;path $_} | export-csv "gplink.all" </em></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/99/75/metablogapi/1738.071013_1521_GetGpLinkcm14.png" original-url="https://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-75-metablogapi/1738.071013_5F00_1521_5F00_GetGpLinkcm14.png" alt="" /></p>
<p>You now have a "backup" of all your domain gplinks.</p>
<p><span style="text-decoration: underline;"><strong>Limitations: </strong></span></p>
<p>This is just the first version of <em>get-gplink</em>. I plan you adding other functions such as reporting external linked GPOs and running the command against Sites as well. Stay tune for the updates.</p>
<p>You can find the script <a title="get-gplink" href="https://gallery.technet.microsoft.com/PowerShell-function-to-545abb28">here</a></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
  </channel>
</rss>