# Setting file variables, local folders or UNC shares are permitted.
$path = 'C:'
$domain = Get-ADDomain
$GPOs = Get-GPO -all -server myserver.mydomain.comยท
# Backup the GPOs
Backup-Gpo -All -Path $path
# Generating HTML reports
$GPOs | ForEach-Object {
$dname = $_.DisplayName
##############################################################################
# For an individual Report
Get-GPOReport -name ($dname) -ReportType Html -Path "C:\$dname.html"}
$Searcher = New-Object -TypeName System.DirectoryServices.DirectorySearcher
$Searcher.SearchRoot = "LDAP://DC=snet,dc=crouse,dc=org"
$Searcher.SearchScope = "subtree"
$Searcher.Filter = "(objectClass=organizationalUnit)"
$Searcher.PropertiesToLoad.Add('Distinguishedname') | Out-Null
$LDAP_OUs = $Searcher.FindAll()
$OUs = $LDAP_OUs.properties.distinguishedname
$OUs | foreach { (Get-GPInheritance -Target $_).GPOlinks } | Select @{name = "GPO Name" ; Expression = {$_.Displayname}} , @{name = "Link Location" ; Expression = {$_.Target}} | sort -Property "GPO Name"| Group-Object -Property 'GPO Name' | ForEach-Object {
New-Object -TypeName PSCustomObject -Property @{
'GPO Name' = $_.Name
'Links' = ($_.Group | ForEach-Object {$_.'Link Location'}) -join ';'
} | Select-Object -Property 'GPO Name',{$_.Links}|export-csv -path out.csv -Append
}
#http://community.idera.com/powershell/ask_the_experts/f/active_directory__powershell_remoting-9/21616/list-of-all-gpo-s-with-their-links
$perms = Foreach ($GPO in (Get-GPO -All | Where {$_.DisplayName -like "*"})){
Foreach ($Perm in (Get-GPPermissions $GPO.DisplayName -All | Where {$_.Permission -eq "GpoApply"})) {
New-Object PSObject -property @{GPO=$GPO.DisplayName;Trustee=$Perm.Trustee.Name;Permission=$Perm.Permission}
}
}
$perms | Select GPO,Trustee,Permission|export-csv -path out_filtering.csv -Append
#https://social.technet.microsoft.com/Forums/office/en-US/6d717266-e641-47df-807e-4d579f6f914f/gpo-report-with-security-filtering?forum=winserverpowershell
import-module ActiveDirectory Get-ADGroupMember "DL CH Lawson Supervisors" | Select samAccountName | out-file c:\dropbox\lawson.txt