Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

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
Avatar of puppydogbuddy
puppydogbuddy

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).
Avatar of bsharath

ASKER

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

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?
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
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
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
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
ASKER CERTIFIED SOLUTION
Avatar of rejoinder
rejoinder
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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  
---------------------------
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.
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"

I think you are missing a "\" in that one line - try this...
xmlDoc.load("C:\GPOXML\" & xmlfile &".xml")
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  
---------------------------
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")
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?
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.
Thank U Works perfect... :-))