Posts

Showing posts from February, 2018

GPO - Get GPO permission details

The below PowerShell script will export the permission details of all matching GPO to CSV file. #Import Group Policy Module Import-Module GroupPolicy #Get current path $invocation = (Get-Variable MyInvocation).Value $directorypath = Split-Path $invocation.MyCommand.Path # Define Variables $MatchPattern = "TestGPO-" $OutFile = $directorypath + "\Result.csv" $OutFile Set-Content $OutFile "" $GPO=get-gpo -all | where {$_.displayname -match $MatchPattern} |foreach {     $GPOName = $_.DisplayName;         $GPOPerm= Get-GPPermissions $GPOName -All     foreach($GPOtrustee in $GPOPerm)     {      $Result= $GPOName + "," + $GPOtrustee.Trustee.Name +","+ $GPOtrustee.Permission      Write-Host $Result      Add-Content $OutFile $Result         }      }