Created
December 4, 2019 19:39
-
-
Save alexverboon/a1bf17bcb0a31213c679429b962477cc to your computer and use it in GitHub Desktop.
GPODump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prepare Folder Structure" | |
If (-not (Test-Path -Path "C:\TEMP\GPO" -PathType Container )) | |
{ | |
New-Item -Path "C:\TEMP\GPO" -ItemType "Directory" | |
New-Item -Path "C:\TEMP\GPO\Backup" -ItemType "Directory" | |
New-Item -Path "C:\TEMP\GPO\Reports" -ItemType "Directory" | |
} | |
Else | |
{ | |
If (-not (Test-Path -Path "cC:\TEMP\GPO\Backup" -PathType Container )) | |
{ | |
New-Item -Path "C:\TEMP\GPO\Backup" -ItemType "Directory" | |
} | |
If (-not (Test-Path -Path "cC:\TEMP\GPO\Reports" -PathType Container )) | |
{ | |
New-Item -Path "C:\TEMP\GPO\Reports" -ItemType "Directory" | |
} | |
} | |
# Gather all GPOs | |
$AllGPO = Get-GPO -All # | |
# Filter those that are of interest | |
$AllInfoGpo = $AllGPO | |
# add a pattern when there are too many GPO objects and the customer has a naming convention to filter out the GPOs you need. | |
#| Where-Object {$_.DisplayName -like "*pattern*"} | |
# Generate a Report and a Backup of each GPO Object | |
ForEach ($gpo in $AllInfoGpo) | |
{ | |
Write-Output "Generating GPO Report for $($gpo.DisplayName)" | |
Get-GPOReport -Name "$($gpo.DisplayName)" -ReportType Html -Path "C:\Temp\gpo\reports\$($gpo.DisplayName).html" | |
Write-Output "Generating Backup for $($gpo.DisplayName)" | |
If (Test-path -Path "C:\Temp\GPO\backup\$($gpo.DisplayName)") | |
{} | |
Else | |
{New-Item -Path "C:\Temp\gpo\backup\$($gpo.DisplayName)" -ItemType "directory" | |
} | |
Backup-GPO -Name "$($gpo.DisplayName)" -Path "C:\Temp\gpo\backup\$($gpo.DisplayName)" -Comment "$($gpo.DisplayName)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment