question

johnarnoldsamson-7683 avatar image
0 Votes"
johnarnoldsamson-7683 asked johnarnoldsamson-7683 commented

Get-gporeport for all ou that is linked with every gpo

Hi guys, im stuck with this.

I'm creating a folder for each of my OU then getting the GPO report for each gpo that is linked in my ou then storing that reports to my folder that i created that is named
each ou.

$OUs = Get-ADOrganizationalUnit -Filter 'Name -like "*"'
$directory = foreach($ou in $ous){ new-item -name $ou.name -ItemType directory -path C:\temp\test}

$like = foreach($ou in $ous){Get-GPInheritance -Target $ou}


foreach($pol in $like){if ($pol.path -eq $ou.Name){foreach($link in $pol.GpoLinks){Get-GPOReport -Name $link -ReportType html -path }}}

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered johnarnoldsamson-7683 commented

Hi,

Please check to see if this works.

 $OUs = Get-ADOrganizationalUnit -Filter 'Name -like "*"'
 foreach($ou in $ous){ 
     $directory = new-item -name $ou.name -ItemType directory -path C:\temp\test
     (Get-GPInheritance -Target $ou).GpoLinks.DisplayName | ForEach-Object {
         if($_){
             Get-GPOReport -Name $_ -ReportType Html -Path "C:\temp\test\$($OU.name)\$($_).html" 
         }
     }
 }

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you so much!!! it works !!!

0 Votes 0 ·