Does this vbs script work for anyone. if yes can i know the steps please.

Hi,
Does this vbs script work for anyone. if yes can i know the steps please.
its mentioned a GPO documentation which is what i am looking for.


http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/easily-document-group-policy-objects-in-microsoft-word-using-vbscript-with-the-microsoftxmldom-and-wordapplication-objects/

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

puppydogbuddyCommented:
I don't understand the question.  The article you referenced contains hyperlink to the GPO download (see this link:     http://www.microsoft.com/downloads/details.aspx?FamilyId=0A6D4C24-8CBD-4B35-9272-DD3CBFC81887&displaylang=en)

The vbScript you posted is referenced in # 6 of the overview of the download, which says Key features delivered via GPMC include:
1. A unified graphical user interface (GUI) that makes Group Policy much easier to use.
2. Backup/restore of Group Policy objects (GPOs).
3. Import/export and copy/paste of GPOs and Windows Management Instrumentation (WMI) filters.
4. Simplified management of Group Policy–related security.
5. HTML reporting for GPO settings and Resultant Set of Policy (RSoP) data.
6. Scripting of Group Policy related tasks that are exposed within this tool (not scripting of settings within a GPO).
0
bsharathAuthor Commented:
I am talking about the code in the link. Thats here below
 set xmlDoc=CreateObject(”Microsoft.XMLDOM”)
Set objWord = CreateObject(”Word.Application”)
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

‘This is the actual name of the XML document minus the path and the “.XML” extension, it becomes the word doc header
xmlfile = “Locked Down Desktop Policy”

objSelection.Font.Name = “Arial”
objSelection.Font.Size = “18¿
objSelection.Font.Bold = True
objSelection.TypeText xmlfile & VbCrLf

objSelection.Font.Bold = False
objSelection.Font.Size = “10¿

xmlDoc.async=”false”
xmlDoc.load(xmlfile &”.xml”)
for each x in xmlDoc.documentElement.childNodes
If x.nodename = “Computer” or x.nodename = “User” Then
For Each y In x.childnodes
if y.Nodename = “ExtensionData” then
For Each z In y.childnodes
If z.Nodename = “Extension” Then
For Each setting In z.childnodes
objSelection.TypeText “______________________________________” & vbCr
DocumentPolicy(Setting)
Next
End if
Next
End if
Next
End If
Next
objDoc.SaveAs(”C:\” & xmlfile & “.doc”)
objWord.Quit
Function DocumentPolicy(Setting)
‘this function basically cleans up the headers of the word document, so they are more human readable
Select Case setting.nodename
Case “q1:Policy”
replacestr = “q1:”
Case “q1:DropDownList”
replacestr = “q1:”
Case “q1:Name”
replacestr = “q1:”
Case “q1:Value”
replacestr = “q1:”
Case “q1:State”
replacestr = “q1:”
Case “q2:Audit”
replacestr = “q2:”
Case “q2:SecurityOptions”
replacestr = “q2:”
Case “q2:EventLog”
replacestr = “q2:”
Case “q2:RestrictedGroups”
replacestr = “q2:”
Case “q2:File”
replacestr = “q2:”
Case “q2:Display”
replacestr = “q2:”
Case “q3:General”
replacestr = “q3:”
Case “q3:HashRule”
replacestr = “q3:”
Case “q3:PathRule”
replacestr = “q3:”
Case “q3:InternetZoneRule”
replacestr = “q3:”
Case “q4:AutoEnrollmentSettings”
replacestr = “q4:”
Case “q4:AutoEnrollmentSettings”
replacestr = “q4:”
Case “q4:RootCertificateSettings”
replacestr = “q4:”
Case “q4:EFSSettings”
replacestr = “q4:”
Case “q5:PreferenceMode”
replacestr = “q5:”
Case “q2:PreferenceMode”
replacestr = “q2:”
Case “q2:ProxySettings”
replacestr = “q2:”
Case “q2:UseSameProxy:”
replacestr = “q2:”
Case “q2:HTTP:”
replacestr = “q2:”
Case “q2:NoProxyIntranet:”
replacestr = “q2:”End Select
objSelection.Font.Bold = True
objSelection.TypeText VbCrLf & replace(setting.nodename, replacestr,””) & VbCrLf
objSelection.Font.Bold = False
For Each Value In Setting.Childnodes
NodeName = replace(Value.nodename,replacestr,””)
If NodeName = “Explain” Then
objSelection.Font.Bold = True
objSelection.TypeText Nodename & “: ” & vbcrlf
objSelection.Font.Bold = False
objSelection.TypeText vbTab & replace(value.text,”\n\n”, VbCrLf & VbCrLf & vbTab )& vbcrlf
Else
objSelection.Font.Bold = True
objSelection.TypeText Nodename & “: “
objSelection.Font.Bold = False
objSelection.TypeText vbtab & value.text & vbcrlf
End if
Next
If isnull(Setting.childnodes) Then
For Each node In Setting.childnodes
DocumentPolicy(node)
next
End if
objSelection.TypeText VbCrLfEnd FunctionNow, when you run this script agains your export there may be some XML tags I didn’t notice because a setting you set is one I didn’t set. Any time you see them in the document you can add a new Case statement in the select case followed by setting the replacestr to the string you want to replace with a null. The lines I’m talking about look similar to this:

  Case “q2:xxxxxxxx”
replacestr = “q2:”

Open in new window

0
markdmacCommented:
Rather than me trying to figure out what someone else's code is supposed to be doing, can you comment on what it is that you are trying to accomplish?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

bsharathAuthor Commented:
Mark
I want to get each Group policies settings into an excel.
say i have 100 GPO's I want each GPO setting into each sheet. So later i could check what is the difference between each and find if there are more than 1 GPO that has been set to do the same thing and even have it as a documentation for my company.
Something as attachment or something similar that can get all thats there in GPO and all that has been set to do as

GPO-Documentation.xlsx
0
markdmacCommented:
There are tools that already do this.  You might want to check out the following:
http://www.microsoft.com/windowsserver2003/technologies/management/grouppolicy/gptools.mspx
0
bsharathAuthor Commented:
Mark i went through the link but could not find a specific one that could document as my attachment
Any views on which does it
0
markdmacCommented:
GPOAdmin from NetPro: GPO Reporting: Extends GPMC’s capabilities and provides advanced reporting features required in larger AD deployments including search for what GPO(s) has a particular setting, unlinked GPOs within the environment, cross-domain linked within the forest, ineffective GPOs Linked but Disabled or not linked
0
rejoinderCommented:
Here is a cleaned up version of the same script.  First open the group policy editor.  Scroll down to the Group Policy Objects folder.  Right click on a GPO and select "Save Report".  Change the save type to XML.  The script will only process one XML file per run so edit the script (line 7) so that the variable matches the XML file but without the .XML portion of the file name.  You may have to alter the path to match you environment (line 18 and 36).
Run the script and review the word document.
The word document only displays very basic info. For a better looking report you can right click the GPO, select "Save Report" and save the file as HTML.

set xmlDoc=CreateObject("Microsoft.XMLDOM")
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

'This is the actual name of the XML document minus the path and the ".XML" extension, it becomes the word doc header
xmlfile = "Cached Exchange Mode"

objSelection.Font.Name = "Arial"
objSelection.Font.Size = "18"
objSelection.Font.Bold = True
objSelection.TypeText xmlfile & VbCrLf

objSelection.Font.Bold = False
objSelection.Font.Size = "10"

xmlDoc.async="false"
xmlDoc.load("C:\temp\" & xmlfile &".xml")
for each x in xmlDoc.documentElement.childNodes
	If x.nodename = "Computer" or x.nodename = "User" Then
		For Each y In x.childnodes
			if y.Nodename = "ExtensionData" then
				For Each z In y.childnodes
					If z.Nodename = "Extension" Then
						For Each setting In z.childnodes
							objSelection.TypeText "______________________________________" & vbCr
							DocumentPolicy(Setting)
						Next
					End if
				Next
			End if
		Next
	End If
Next

objDoc.SaveAs("C:\temp\" & xmlfile & ".doc")
objWord.Quit

Function DocumentPolicy(Setting)
	'this function basically cleans up the headers of the word document, so they are more human readable
	Select Case setting.nodename
		Case "q1:Policy"
			replacestr = "q1:"
		Case "q1:DropDownList"
			replacestr = "q1:"
		Case "q1:Name"
			replacestr = "q1:"
		Case "q1:Value"
			replacestr = "q1:"
		Case "q1:State"
			replacestr = "q1:"
		Case "q2:Audit"
			replacestr = "q2:"
		Case "q2:SecurityOptions"
			replacestr = "q2:"
		Case "q2:EventLog"
			replacestr = "q2:"
		Case "q2:RestrictedGroups"
			replacestr = "q2:"
		Case "q2:File"
			replacestr = "q2:"
		Case "q2:Display"
			replacestr = "q2:"
		Case "q3:General"
			replacestr = "q3:"
		Case "q3:HashRule"
			replacestr = "q3:"
		Case "q3:PathRule"
			replacestr = "q3:"
		Case "q3:InternetZoneRule"
			replacestr = "q3:"
		Case "q4:AutoEnrollmentSettings"
			replacestr = "q4:"
		Case "q4:AutoEnrollmentSettings"
			replacestr = "q4:"
		Case "q4:RootCertificateSettings"
			replacestr = "q4:"
		Case "q4:EFSSettings"
			replacestr = "q4:"
		Case "q5:PreferenceMode"
			replacestr = "q5:"
		Case "q2:PreferenceMode"
			replacestr = "q2:"
		Case "q2:ProxySettings"
			replacestr = "q2:"
		Case "q2:UseSameProxy:"
			replacestr = "q2:"
		Case "q2:HTTP:"
			replacestr = "q2:"
		Case "q2:NoProxyIntranet:"
			replacestr = "q2:"
	End Select
	objSelection.Font.Bold = True
	objSelection.TypeText VbCrLf & replace(setting.nodename, replacestr,"") & VbCrLf
	objSelection.Font.Bold = False
	For Each Value In Setting.Childnodes
		NodeName = replace(Value.nodename,replacestr,"")
		If NodeName = "Explain" Then
			objSelection.Font.Bold = True
			objSelection.TypeText Nodename & ": " & vbcrlf
			objSelection.Font.Bold = False
			objSelection.TypeText vbTab & replace(value.text,"\n\n", VbCrLf & VbCrLf & vbTab )& vbcrlf
		Else
			objSelection.Font.Bold = True
			objSelection.TypeText Nodename & ": "
			objSelection.Font.Bold = False
			objSelection.TypeText vbtab & value.text & vbcrlf
		End if
	Next
	If isnull(Setting.childnodes) Then
		For Each node In Setting.childnodes
			DocumentPolicy(node)
		next
	End if
	objSelection.TypeText VbCrLf
End Function

'Now, when you run this script against your export there may be some XML tags I 
'didn’t notice because a setting you set is one I didn’t set. Any time you see 
'them in the document you can add a new Case statement in the select case followed 
'by setting the replacestr to the string you want to replace with a null. The 
'lines I’m talking about look similar to this:
'Case "q2:xxxxxxxx"
'replacestr = "q2:"

wscript.echo "Done"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bsharathAuthor Commented:
Rejoinder
I get this
---------------------------
Windows Script Host
---------------------------
Script:      C:\GPOXML.vbs
Line:      19
Char:      1
Error:      Object required: 'xmlDoc.documentElement'
Code:      800A01A8
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------
0
rejoinderCommented:
OK - so you opened the GPO and saved it as a XML file into C:\Temp\My GPO Name.xml right?  Your GPO name will vary of course.
Then on line 7 you entered the text "My GPO Name" with no .xml in it, just the name.  The output will go to C:\Temp as well.
0
bsharathAuthor Commented:
Yes
I have the line as this in the code
xmlDoc.load("C:\GPOXML" & xmlfile &".xml")

This is the file path
C:\GPOXML\Lockdown.xml
And this line in code as
xmlfile = "Lockdown"

0
rejoinderCommented:
I think you are missing a "\" in that one line - try this...
xmlDoc.load("C:\GPOXML\" & xmlfile &".xml")
0
bsharathAuthor Commented:
I get this now

---------------------------
Windows Script Host
---------------------------
Script:      C:\GPOXML.vbs
Line:      36
Char:      1
Error:      This is not a valid file name.
Try one or more of the following:
* Check the path to make sure it was typed correctly.
* Select a file from the list of files and folders.
Code:      800A1420
Source:       Microsoft Word

---------------------------
OK  
---------------------------
0
rejoinderCommented:
Can you double check that the drive and folder mentioned in line 36 exist?  It should not be saved to the root of C: drive so you could use something similar to the XML location.  Can you try this in line 36...
objDoc.SaveAs("C:\GPOXML\" & xmlfile & ".doc")
0
bsharathAuthor Commented:
Should i place lines as this?
xmlDoc.load("C:\GPOXML\" & xmlfile &".xml")
objDoc.SaveAs("C:\GPOXML\" & xmlfile & ".doc")

When i checked the processes in task manager
Each time i ran the winword stats a process and does not stop.
So i end task the winword process and opened a blank word file where i could see autorecoved word files when clicked 1 i could see the word format i wanted

But how can i get it without the errors
And
I mention the xml file name alone in the code and the C:\GPOXML\ to point the script to the path where Xml file is saved
where does it try to save the word file?
0
rejoinderCommented:
To resolve the Word process running on and on, change line 37 from
objWord.Quit
to
objWord.visible = True

For now the Word file is being saved to the same location as the XML file.  To change that location of the Word file, edit line 36.
0
bsharathAuthor Commented:
Thank U Works perfect... :-))
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.