Skip to content

Instantly share code, notes, and snippets.

@techdecline
Created May 22, 2019 12:58
Show Gist options
  • Select an option

  • Save techdecline/1527c8126b1bdb707386cefe855c5141 to your computer and use it in GitHub Desktop.

Select an option

Save techdecline/1527c8126b1bdb707386cefe855c5141 to your computer and use it in GitHub Desktop.
<#
.Synopsis
Get Group Policy Object Id that have been applied in the past
.DESCRIPTION
Get Group Policy Object Id that have been applied in the past
.EXAMPLE
Get-GpoHistory -Scope Machine
#>
function Get-GpoHistory
{
[CmdletBinding()]
Param
(
# Hilfebeschreibung zu Param1
[Parameter(Mandatory=$false)]
[ValidateSet("Machine")]
[String]$Scope
)
Process {
$gpoObjHist = @()
$key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\History'
$gpoHistArr = Get-ChildItem -Path $key
$gpoHistArr | ForEach-Object {Get-ChildItem $_.PSPath} | ForEach-Object {$gpoObjHist += (Get-ItemPropertyValue -Path $_.PSPath -Name DisplayName)}
return $gpoObjHist
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment