Generate_GPO_Settings_Report.wsf (In the book)

Jan
25
2013

 

<job>
<comment>
Script : List_GPMC_Information.wsf
From the book "Group Policy" by Jeremy Moskowitz

The contents of this script are provided "as is".  
No warranty of any kind, either express or implied, is made in relation 
to the availability, accuracy, reliability or content of this script.
ALWAYS test scripts before using in your production network!
</comment>
<script language="VBScript" src="GPMgmt.vbs" />
<script>
CheckCScript
CreateGPMObjects
If WSH.Arguments.Count > 0 Then
    If WSH.Arguments.Named.Exists("Folder") Then
        ReportFolder = WSH.Arguments.Named("Folder")
        If Not(Right(ReportFolder,1) = "\") Then
            ReportFolder = ReportFolder & "\"
        End If
    Else
        ReportFolder = WScript.Path
    End If
    If WSH.Arguments.Named.Exists("UseDate") Then
        ReportFolder = ReportFolder & GetDateName & "\"
    End If
    If WSH.Arguments.Named.Exists("XML") Then
        ReportFormat = gpmConstants.reportXML
        ReportSuffix = ".XML"
    Else
        ReportFormat = gpmConstants.reportHTML
        ReportSuffix = ".HTML"
    End If
Else
    WScript.Echo "Missing arguments"
End If

Set FSO = CreateObject("Scripting.FileSystemObject")
If Not(FSO.FolderExists(ReportFolder)) Then
    FSO.CreateFolder ReportFolder
End If


WScript.Echo "Creating GPO reports to " & ReportFolder

set gpmSearchCriteria = gpm.CreateSearchCriteria()
set GPO_List = gpmDomain.SearchGPOs(gpmSearchCriteria)

For Each GPO In GPO_List
	WScript.Echo "Generating report for " & gpo.DisplayName & "..."
	ReportName = ReportFolder & "GPO Report - " & GPO.DisplayName & ReportSuffix
	Set gpmResult = gpo.GenerateReportToFile(ReportFormat, ReportName)
	Set gpmResult_Status = gpmResult.Status
	If gpmResult_Status.count <> 0 Then 
		For i=1 to gpmResult_Status.Count
			WScript.Echo gpmResult_Status.Item(i).Message
		Next
		gpmResult.OverallStatus()
	Else
		WScript.Echo vbTab & "Report generated."
	End If
Next

Wscript.Echo "Completed report generation."


</script>
</job>
Copyright © GPanswers.com. All rights reserved. GPanswers.com is a service of PolicyPak Software