{"id":8031,"date":"2015-02-01T00:01:00","date_gmt":"2015-02-01T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/02\/01\/weekend-scripter-use-powershell-to-troubleshoot-group-policy-part-2\/"},"modified":"2019-02-18T10:35:39","modified_gmt":"2019-02-18T17:35:39","slug":"weekend-scripter-use-powershell-to-troubleshoot-group-policy-part-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-use-powershell-to-troubleshoot-group-policy-part-2\/","title":{"rendered":"Weekend Scripter: Use PowerShell to Troubleshoot Group Policy Part 2"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Guest blogger, Alex Verboon, continues his series about using Windows PowerShell to troubleshoot Group Policy.<\/span><\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Welcome back guest blogger, Alex Verboon. Today Alex adds to his previous blog about using Windows PowerShell to troubleshoot Group Policy. He provides a script that automates this process. You can read his blog at <a href=\"http:\/\/www.verboon.info\/\" target=\"_blank\">Anything about IT<\/a>.<\/p>\n<p>Take it away Alex&hellip;<\/p>\n<p>In my previous post, <a href=\"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-use-powershell-to-troubleshoot-group-policy\/\" target=\"_blank\">Use PowerShell to Troubleshoot Group Policy<\/a>, I shared a script that retrieves the Group Policy processing time. As shown here, when specifying the optional <b>&ndash;ShowDetails<\/b> switch, the <a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/Get-GPProcessingTime-a124aaf5\" target=\"_blank\">Get-GPProcessingTime<\/a> script output also displays the Correlation:ActivityID that represents one instance of Group Policy processing.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-2-1-15-1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-2-1-15-1.png\" border=\"0\" alt=\" \" \/><\/a><\/p>\n<p>To get all the details of what happened during that Group Policy processing cycle, we simply retrieve all events that have the corresponding ActivityID:<\/p>\n<p style=\"margin-left:30px\">Get-GPEventByCorrelationID -Computer TestClient1 -CorrelationID f7cb68e1-f6da-4d23-8fca-c4cb85158de2<\/p>\n<p>Here is the script output:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-2-1-15-2.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-2-1-15-2.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>Following is the full script. You can download this script from the Script Center Repository at <a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/Get-GPEventByCorrelationID-97944972\" target=\"_blank\">Get-GPEventByCo\u200brrelationID<\/a>.<\/p>\n<p style=\"margin-left:30px\">function Get-GPEventByCorrelationID<\/p>\n<p style=\"margin-left:30px\">{<\/p>\n<p style=\"margin-left:30px\">&lt;#<\/p>\n<p style=\"margin-left:30px\">.Synopsis<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp; Get Group Policy Eventlog entries by Correlation ID<\/p>\n<p style=\"margin-left:30px\">.DESCRIPTION<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp; This function retrieves Group Policy event log entries filtered by Correlation ID from the specified computer<\/p>\n<p style=\"margin-left:30px\">.EXAMPLE<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp; Get-GPEventByCorrelationID -Computer TestClient -CorrelationID A2A621EC-44B4-4C56-9BA3-169B88032EFD<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">TimeCreated&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Id LevelDisplayName Message&nbsp;&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R59104$ will be attempted in&#8230;<\/p>\n<p style=\"margin-left:30px\">7\/28\/2014 5:31:31 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8002 Information&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Completed policy processing due to network state change for co&#8230;<\/p>\n<p style=\"margin-left:30px\">7\/28\/2014 5:31:31 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;5016 Information&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Completed Audit Policy Configuration Extension Processing in 0&#8230;<\/p>\n<p style=\"margin-left:30px\">&#8230;&#8230;.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">#&gt;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; [CmdletBinding()]<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Param<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; (<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory=$true,<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ValueFromPipelineByPropertyName=$true,<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HelpMessage=&quot;Enter Computername(s)&quot;,<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Position=0)]<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [String]$Computer = &quot;localhost&quot;,<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # CorrelationID<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Parameter(Mandatory=$true,<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ValueFromPipelineByPropertyName=$true,<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HelpMessage=&quot;Enter CorrelationID&quot;,<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Position=0)]<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [string]$CorrelationID<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Begin<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Query = &#039;&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=&quot;{CorrelationID}&quot;]&lt;\/Select&gt;&lt;\/Query&gt;&lt;\/QueryList&gt;&#039;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$FilterXML = $Query.Replace(&quot;CorrelationID&quot;,$CorrelationID)<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Process<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $orgCulture = Get-Culture<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [System.Threading.Thread]::CurrentThread.CurrentCulture = New-Object &quot;System.Globalization.CultureInfo&quot; &quot;en-US&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $gpevents = Get-WinEvent -FilterXml $FilterXML -ComputerName $Computer<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [System.Threading.Thread]::CurrentThread.CurrentCulture = $orgCulture<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; End<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [System.Threading.Thread]::CurrentThread.CurrentCulture = New-Object &quot;System.Globalization.CultureInfo&quot; &quot;en-US&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $gpevents | Format-Table -Wrap -AutoSize -Property TimeCreated, Id, LevelDisplayName, Message<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [System.Threading.Thread]::CurrentThread.CurrentCulture = $orgCulture<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">}<\/p>\n<p>In addition to what I have posted here and in the Script Center Repository, I found the following script written by Thomas Bouchereau (PFE), which is similar: <a href=\"https:\/\/gallery.technet.microsoft.com\/Group-Policy-processing-134c747b\" target=\"_blank\">Group Policy processing events collection with PowerShell<\/a>.<\/p>\n<p>~Alex<\/p>\n<p>Thank you, Alex, for sharing your time and knowledge. This is an awesome script and I wanted to make sure we shared it with the community. Join me tomorrow when Windows PowerShell MVP, Richard Siddaway, begins a great series about working with the registry. You will not want to miss it.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Guest blogger, Alex Verboon, continues his series about using Windows PowerShell to troubleshoot Group Policy. Microsoft Scripting Guy, Ed Wilson, is here. Welcome back guest blogger, Alex Verboon. Today Alex adds to his previous blog about using Windows PowerShell to troubleshoot Group Policy. He provides a script that automates this process. You can read [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[532,152,56,3,61,45],"class_list":["post-8031","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-alex-verboon","tag-group-policy","tag-guest-blogger","tag-scripting-guy","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Guest blogger, Alex Verboon, continues his series about using Windows PowerShell to troubleshoot Group Policy. Microsoft Scripting Guy, Ed Wilson, is here. Welcome back guest blogger, Alex Verboon. Today Alex adds to his previous blog about using Windows PowerShell to troubleshoot Group Policy. He provides a script that automates this process. You can read [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/8031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=8031"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/8031\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=8031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=8031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=8031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}