-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-gpinfo.ps1
46 lines (37 loc) · 1.1 KB
/
get-gpinfo.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<#
.SYNOPSIS
Checks GPReport.xml files from GPO export, and pulls gpo name and path
.DESCRIPTION
Checks GPO path
Pulls XML tag gpo.name
Adds gpo name and path to an array and outputs it
.EXAMPLE
.\Get-GPOInfo.ps1 -GPOPath "C:\GPOExp"
Input parameters mandatory:
-GPOPath path to gpo export/backup folder
#>
[CmdLetBinding()]
Param (
[ValidateNotNullOrEmpty()]
[ValidateScript({Test-Path $_)]
[Parameter(
Mandatory=$True,
HelpMessage="Specify path to GPO export folder",
Position=1
)]
[String]$GPOPath
)
If($GPOPath[-1] -like "\"){
$GPOPath = $GPOPath.Substring(0,$GPOPath.Length-1)
}
$Result = @()
$GPOs = GCI $GPOPath -Filter "{*" -Directory
ForEach($GPO in $GPOPath){
$Path = $GPOPath + "\$gpo\gpreport.xml"
[XML]$GPReport = Get-Content $Path
$GPOObj = New-Object System.Object
$GPOObj | Add-Member -Type NoteProperty -Name GPOName -Value $GPReport.GPO.Name
$GPOObj | Add-Member -Type NoteProperty -Name GPOPath -Value ($GPOPath + "\$GPO")
$Result += $GPOObj
}
Return $Result