{"id":8041,"date":"2021-01-18T12:31:31","date_gmt":"2021-01-18T17:31:31","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=8041"},"modified":"2021-01-18T12:31:38","modified_gmt":"2021-01-18T17:31:38","slug":"get-group-policy-links-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/","title":{"rendered":"Get Group Policy Links with PowerShell"},"content":{"rendered":"\n<p>I was chatting with my friend Gladys Kravitz about Group Policy reporting stuff recently,. and the discussion led me to dust off some old code I had for getting Group Policy links using PowerShell. The GroupPolicy module has a Set-GPLink command, but nothing that easily shows you what GPOs are linked to your site, domain and OUs. Even though you may not need such a report, I'm hoping there is something in my scripting techniques that you will find helpful.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Start with a Core Command<\/h2>\n\n\n\n<p>As with any PowerShell project, you want to start from the console. Can you run a command interactively that give you the essence of your goal? In my case, this is the Get-GPInheritance cmdlet from the GroupPolicy module. I'll count on your to read help and examples. Here's how it shows me what is linked at the domain level.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"287\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1-1024x287.png\" alt=\"\" class=\"wp-image-8042\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1-1024x287.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1-300x84.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1-768x215.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1-850x238.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png 1216w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>In looking at the output, I see a property that probably has the information I'm after.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"350\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-2-1024x350.png\" alt=\"\" class=\"wp-image-8043\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-2-1024x350.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-2-300x103.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-2-768x263.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-2-1536x525.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-2-850x291.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-2.png 1602w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>This looks promising. I can verify it works with organizational units as well.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">(Get-ADOrganizationalUnit -filter * | Get-GPInheritance).GpoLinks | \n Select-Object -Property Target,DisplayName,Enabled,Enforced,Order |\n Format-Table<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"324\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-3-1024x324.png\" alt=\"\" class=\"wp-image-8044\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-3-1024x324.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-3-300x95.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-3-768x243.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-3-1536x486.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-3-850x269.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-3.png 1638w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>This looks pretty good and is close to what I was hoping to accomplish. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Querying Site Links<\/h2>\n\n\n\n<p>What about sites? Assuming I don't know the distinguished names of all my sites, I want a programmatic solution.  I can use the ActiveDirectory module to discover sites.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$getADO = @{\n     LDAPFilter = \"(Objectclass=site)\"\n     properties = \"Name\"\n     SearchBase = (Get-ADRootDSE).ConfigurationNamingContext\n }\n $sites = Get-ADObject @getADO<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpsite.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"429\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpsite-1024x429.png\" alt=\"\" class=\"wp-image-8045\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpsite-1024x429.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpsite-300x126.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpsite-768x322.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpsite-1536x644.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpsite-850x356.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpsite.png 2033w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>I only have a single site but unfortunately Get-GPInheritance can't use sites. There are ways to dig through Active Directory and parse out site links,  but I decided to take an easier way and fall back on the legacy COM object, GPMGMT.GPM. Here's how.<\/p>\n\n\n\n<p>First, I need an object reference. I'm also going to get all of the constants the object requires.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$gpm = New-Object -ComObject \"GPMGMT.GPM\"\n$gpmConstants = $gpm.GetConstants()<\/code><\/pre>\n\n\n\n<p>I'm going to need references to the domain and forest.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$gpmdomain = $gpm.GetDomain(\"company.pri\", \"\", $gpmConstants.UseAnyDC)\n$SiteContainer = $gpm.GetSitesContainer(\"company.pri\", \"company.pri\", $null, $gpmConstants.UseAnyDC)<\/code><\/pre>\n\n\n\n<p>My domain and forest are called Company.pri.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"312\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-1-1024x312.png\" alt=\"\" class=\"wp-image-8046\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-1-1024x312.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-1-300x91.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-1-768x234.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-1-1536x468.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-1-850x259.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-1.png 1831w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>The $SiteContainer object has a GetSite() method, but it needs the name of a site. But I got that earlier.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"185\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-2-1024x185.png\" alt=\"\" class=\"wp-image-8047\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-2-1024x185.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-2-300x54.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-2-768x139.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-2-1536x278.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-2-850x154.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-2.png 2023w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>This new object has a method called GetGPOLinks().<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"535\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-3-1024x535.png\" alt=\"\" class=\"wp-image-8048\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-3-1024x535.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-3-300x157.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-3-768x401.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-3-850x444.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gpm-3.png 1038w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>That's pretty good. All I'm missing is the GPO name.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$site.GetGPOLinks() | Select GPOId,@{Name=\"DisplayName\";Expression = {$gpmdomain.GetGPO($_.gpoid).Displayname}},Enabled,Enforced,SOMLinkOrder<\/code><\/pre>\n\n\n\n<p>Since I have the GPOId, I can get the GPO. This code is using the COM object. I could have used the cmdlet, but I would need to parse out the {} characters.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$site.GetGPOLinks() | Select GPOId,@{Name=\"DisplayName\";Expression = {(Get-GPO -id ($_.gpoid.replace(\"{|\",\"\"))).Displayname}},Enabled,Enforced,SOMLinkOrder<\/code><\/pre>\n\n\n\n<p>With these pieces in place I can build a PowerShell tool around these code snippets.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Get-GPLink<\/h2>\n\n\n\n<p>I wrote a function called Get-GPLink. Since I am using the GroupPolicy and ActiveDirectory cmdlets, and they support specifying a server and\/or domain, I wanted to support that as well. Initially, I tried to use splatting and dynamically assign parameter values. But this quickly became unwieldy. Instead, I define a script-scope version of $PSDefaultParameter values.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">if\u00a0($Server)\u00a0{\n\u00a0\u00a0\u00a0\u00a0$script:PSDefaultParameterValues[\"Get-AD*:Server\"]\u00a0=\u00a0$server\n\u00a0\u00a0\u00a0\u00a0$script:PSDefaultParameterValues[\"Get-GP*:Server\"]\u00a0=\u00a0$Server\n}\n\nif\u00a0($domain)\u00a0{\n\u00a0\u00a0\u00a0\u00a0$script:PSDefaultParameterValues[\"Get-AD*:Domain\"]\u00a0=\u00a0$domain\n\u00a0\u00a0\u00a0\u00a0$script:PSDefaultParameterValues[\"Get-ADDomain:Identity\"]\u00a0=\u00a0$domain\n\u00a0\u00a0\u00a0\u00a0$script:PSDefaultParameterValues[\"Get-GP*:Domain\"]\u00a0=\u00a0$domain\n}<\/code><\/pre>\n\n\n\n<p>Now I don't have to worry about it If I run Get-ADDomain and the Server parameter is used from my function, the Get-ADDomain cmdlet will automatically use it.<\/p>\n\n\n\n<p>The function goes through and queries the domain and organizational units using the GroupPolicy module. Site level links are retrieved using the COM object. Technically, I could have used the COM object for everything. <\/p>\n\n\n\n<p>The function collects all the links which allows me to offer filtering such by GPO name or to show only enabled or disabled links.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"766\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-1-1024x766.png\" alt=\"\" class=\"wp-image-8050\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-1-1024x766.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-1-300x224.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-1-768x575.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-1-850x636.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-1.png 1223w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>That's not too bad. But I always want more. For example, I can't pipe the output of my function to Get-GPO. Although I can, if I make a minor adjustment.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-pipeline.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"414\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-pipeline-1024x414.png\" alt=\"\" class=\"wp-image-8051\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-pipeline-1024x414.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-pipeline-300x121.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-pipeline-768x311.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-pipeline-1536x621.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-pipeline-850x344.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-pipeline.png 1837w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>But I don't want to do that all the time. I'd also like a default output of a table. I know I can do that with a custom format.ps1xml file and my trusty <a href=\"http:\/\/bit.ly\/31SGo5o\" target=\"_blank\" rel=\"noreferrer noopener\">New-PSFormatXML<\/a> command.  But to do that I need a unique and custom type name.<\/p>\n\n\n\n<p>In my code, I can insert a new type name since I'm not creating a custom object from scratch as I usually do.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$results.GetEnumerator().ForEach(\u00a0{\u00a0$_.psobject.TypeNames.insert(0,\u00a0\"myGPOLink\")\u00a0})<\/code><\/pre>\n\n\n\n<p>Once I have a new type name, I can define type extensions.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Update-TypeData\u00a0-MemberType\u00a0AliasProperty\u00a0-MemberName\u00a0GUID\u00a0-Value\u00a0GPOId\u00a0-TypeName\u00a0myGPOLink\u00a0-Force\nUpdate-TypeData\u00a0-MemberType\u00a0AliasProperty\u00a0-MemberName\u00a0Name\u00a0-Value\u00a0DisplayName\u00a0-TypeName\u00a0myGPOLink\u00a0-Force\nUpdate-TypeData\u00a0-MemberType\u00a0AliasProperty\u00a0-MemberName\u00a0GPO\u00a0-Value\u00a0DisplayName\u00a0-TypeName\u00a0myGPOLink\u00a0-Force\nUpdate-TypeData\u00a0-MemberType\u00a0AliasProperty\u00a0-MemberName\u00a0Link\u00a0-Value\u00a0Target\u00a0-TypeName\u00a0myGPOLink\u00a0-Force\nUpdate-TypeData\u00a0-MemberType\u00a0AliasProperty\u00a0-MemberName\u00a0Domain\u00a0-Value\u00a0GpoDomainName\u00a0-TypeName\u00a0myGPOLink\u00a0-Force\nUpdate-TypeData\u00a0-MemberType\u00a0ScriptProperty\u00a0-MemberName\u00a0TargetType\u00a0-Value\u00a0{\n\u00a0\u00a0\u00a0\u00a0switch\u00a0-regex\u00a0($this.target)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"^((ou)|(OU)=)\"\u00a0{\u00a0\"OU\"\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"^((dc)|(DC)=)\"\u00a0{\u00a0\"Domain\"\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"^((cn)|(CN)=)\"\u00a0{\u00a0\"Site\"\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Default\u00a0{\u00a0\"Unknown\"}\n\u00a0\u00a0\u00a0\u00a0}\n}\u00a0-TypeName\u00a0myGPOLink\u00a0-Force<\/code><\/pre>\n\n\n\n<p>This makes it much easier now to work with my Group Policy links.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"609\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-2-1024x609.png\" alt=\"\" class=\"wp-image-8052\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-2-1024x609.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-2-300x179.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-2-768x457.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-2-1536x914.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-2-850x506.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-2.png 1657w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Custom Format<\/h2>\n\n\n\n<p>Of course, since I have a custom type I can create a format.ps1xml file and get really fancy. Now I can create a default table view of the results. And since I'm always looking for ways to add color to PowerShell I decided to highlight disabled links and those that are enforced using ANSI escape sequences.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"xml\" class=\"language-xml\">&lt;TableColumnItem>\n\u00a0\u00a0\u00a0\u00a0&lt;ScriptBlock>\n\u00a0\u00a0\u00a0\u00a0&lt;!--\u00a0use\u00a0ANSI\u00a0formatting\u00a0if\u00a0using\u00a0the\u00a0console\u00a0host-->\n\u00a0\u00a0\u00a0\u00a0if\u00a0($host.name\u00a0-eq\u00a0'ConsoleHost')\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if\u00a0($_.Enabled)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$_.Enabled\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"$([char]0x1b)[1;91m$($_.enabled)$([char]0x1b)[0m\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0else\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$_.Enabled\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0&lt;\/ScriptBlock>\n&lt;\/TableColumnItem><\/code><\/pre>\n\n\n\n<p>The scriptblock only uses ANSI if PowerShell detects a console host. I'm using an escape sequence that will work in both Windows PowerShell and PowerShell 7.x<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"324\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-3-1024x324.png\" alt=\"\" class=\"wp-image-8053\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-3-1024x324.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-3-300x95.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-3-768x243.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-3-1536x486.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-3-850x269.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gplink-3.png 1856w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>The format file includes other view as well.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1019\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view1-1024x1019.png\" alt=\"\" class=\"wp-image-8054\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view1-1024x1019.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view1-300x298.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view1-150x150.png 150w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view1-768x764.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view1-850x846.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view1.png 1188w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"321\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view2-1024x321.png\" alt=\"\" class=\"wp-image-8055\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view2-1024x321.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view2-300x94.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view2-768x240.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view2-850x266.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view2.png 1131w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"543\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view3-1024x543.png\" alt=\"\" class=\"wp-image-8056\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view3-1024x543.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view3-300x159.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view3-768x407.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view3-1536x815.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view3-850x451.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/gplink-view3.png 1731w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>I use the workflow I've just described in much of my work. I start with core commands, build a robust wrapper around the commands in the form of a function, write an object to the pipeline, and if necessary customize with type and format extensions. The end result should be an easy to use and helpful PowerShell tool that runs the in the pipeline like any other PowerShell command.<\/p>\n\n\n\n<p>If you want to see how this all works, I've posted the code as <a href=\"https:\/\/gist.github.com\/jdhitsolutions\/f33ec03729c019efacc738a762d9a725\" target=\"_blank\" rel=\"noreferrer noopener\">a GitHub gist<\/a>. If you want to try it out, you'll need to save both files to the same directory. Pay close attention to the name of the format file since that is loaded when you dot source the function file.<\/p>\n\n\n\n<p>If you have any questions about what I did or why, please feel free to leave a comment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was chatting with my friend Gladys Kravitz about Group Policy reporting stuff recently,. and the discussion led me to dust off some old code I had for getting Group Policy links using PowerShell. The GroupPolicy module has a Set-GPLink command, but nothing that easily shows you what GPOs are linked to your site, domain&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New on the blog: Get Group Policy Links with #PowerShell","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7,287,4,8],"tags":[149,534,646,540],"class_list":["post-8041","post","type-post","status-publish","format-standard","hentry","category-active-directory","category-group-policy","category-powershell","category-scripting","tag-activedirectory","tag-powershell","tag-psformat","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get Group Policy Links with PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here&#039;s how I built a PowerShell tool to show me all the group policy links in my domain using custom objects as well as type and format extensions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Group Policy Links with PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s how I built a PowerShell tool to show me all the group policy links in my domain using custom objects as well as type and format extensions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-18T17:31:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-01-18T17:31:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1-1024x287.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Get Group Policy Links with PowerShell\",\"datePublished\":\"2021-01-18T17:31:31+00:00\",\"dateModified\":\"2021-01-18T17:31:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/\"},\"wordCount\":919,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/get-gpinherticance-1-1024x287.png\",\"keywords\":[\"ActiveDirectory\",\"PowerShell\",\"psformat\",\"Scripting\"],\"articleSection\":[\"Active Directory\",\"Group Policy\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/\",\"name\":\"Get Group Policy Links with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/get-gpinherticance-1-1024x287.png\",\"datePublished\":\"2021-01-18T17:31:31+00:00\",\"dateModified\":\"2021-01-18T17:31:38+00:00\",\"description\":\"Here's how I built a PowerShell tool to show me all the group policy links in my domain using custom objects as well as type and format extensions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/get-gpinherticance-1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/get-gpinherticance-1.png\",\"width\":1216,\"height\":341},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8041\\\/get-group-policy-links-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Group Policy Links with PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get Group Policy Links with PowerShell &#8226; The Lonely Administrator","description":"Here's how I built a PowerShell tool to show me all the group policy links in my domain using custom objects as well as type and format extensions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Get Group Policy Links with PowerShell &#8226; The Lonely Administrator","og_description":"Here's how I built a PowerShell tool to show me all the group policy links in my domain using custom objects as well as type and format extensions.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2021-01-18T17:31:31+00:00","article_modified_time":"2021-01-18T17:31:38+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1-1024x287.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Get Group Policy Links with PowerShell","datePublished":"2021-01-18T17:31:31+00:00","dateModified":"2021-01-18T17:31:38+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/"},"wordCount":919,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1-1024x287.png","keywords":["ActiveDirectory","PowerShell","psformat","Scripting"],"articleSection":["Active Directory","Group Policy","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/","name":"Get Group Policy Links with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1-1024x287.png","datePublished":"2021-01-18T17:31:31+00:00","dateModified":"2021-01-18T17:31:38+00:00","description":"Here's how I built a PowerShell tool to show me all the group policy links in my domain using custom objects as well as type and format extensions.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png","width":1216,"height":341},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Get Group Policy Links with PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":7648,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7648\/updated-powershell-tools\/","url_meta":{"origin":8041,"position":0},"title":"Updated PowerShell Tools","author":"Jeffery Hicks","date":"August 14, 2020","format":false,"excerpt":"I've released a new version of my popular PSScriptTools module, which you can install from the PowerShell Gallery. The module is collection of commands and tools that I use in my scripting and day-to-day work at a PowerShell console. Many of the commands run in Windows PowerShell and PowerShell 7,\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":5833,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5833\/new-powershell-projects-published\/","url_meta":{"origin":8041,"position":1},"title":"New PowerShell Projects Published","author":"Jeffery Hicks","date":"December 18, 2017","format":false,"excerpt":"Last week I published a few of the recent PowerShell modules I've been working on to the PowerShell Gallery. These projects had been in a beta phase while I worked out some last minute features. I was also waiting to see if there were any issues reported by you that\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-6.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-6.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-6.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4169,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4169\/friday-fun-updated-ise-scripting-geek-module\/","url_meta":{"origin":8041,"position":2},"title":"Friday Fun: Updated ISE Scripting Geek Module","author":"Jeffery Hicks","date":"January 9, 2015","format":false,"excerpt":"A few years ago I published a module with a number of functions and enhancements for the PowerShell ISE. This ISEScriptingGeek module has remained popular over the last few years. But I wrote it for PowerShell v2. I have also come up with a number of new additions to the\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"geek","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/01\/geek-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":7468,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7468\/powershell-7-scripting-with-the-powershell-ise\/","url_meta":{"origin":8041,"position":3},"title":"PowerShell 7 Scripting with the PowerShell ISE","author":"Jeffery Hicks","date":"May 11, 2020","format":false,"excerpt":"By now, everyone should have gotten the memo that with the move to PowerShell 7, the PowerShell ISE should be considered deprecated. When it comes to PowerShell script and module development for PowerShell 7, the recommended tool is Visual Studio Code. It is free and offers so much more than\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":7361,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/7361\/powershell-7-cross-platform-scripting-tips-and-traps\/","url_meta":{"origin":8041,"position":4},"title":"PowerShell 7 Cross-Platform Scripting Tips and Traps","author":"Jeffery Hicks","date":"March 13, 2020","format":false,"excerpt":"One of the reasons you want to adopt PowerShell 7 on your desktop, is that it can\u00a0 be used cross-platform. Theoretically, you can write a PowerShell script or function that works on Windows, Linux, and Mac. However, this is not without challenges. In some ways, it feels like we are\u2026","rel":"","context":"In &quot;PowerShell 7&quot;","block_context":{"text":"PowerShell 7","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-7\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/hicks-scripting-4.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/hicks-scripting-4.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/hicks-scripting-4.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/hicks-scripting-4.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2125,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2125\/powershell-ise-addon-modulemenu\/","url_meta":{"origin":8041,"position":5},"title":"PowerShell ISE AddOn ModuleMenu","author":"Jeffery Hicks","date":"February 24, 2012","format":false,"excerpt":"Recently I did an online presentation on ISE Addons. As I was preparing for the talk one thing led to another, as they usually do when I'm working in PowerShell, and before I knew it I had a new add-on for the PowerShell ISE. This addon creates a menu for\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/modulemenu-300x136.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8041"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8041\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}