Solved

Distribute local group policy to mulitple machines in a non-ad environment

Posted on 2006-10-30
13
231 Views
Last Modified: 2012-08-13
I am migrating my workstations from Windows NT4 to Windows XP (yes, a little behind but that's the government for you.)  We won't have the funding to go AD until the first quarter of next year.  I have a WSUS server that I need the XP workstations to see, so I am going to modify the local group policy on the "image" and start ghosting the workstations.  However there are several XP workstations that are already in use and I would rather not visit them unless I have to.  So, the question is, can I create a local gp and then export it to the other XP workstations remotely?  If so, please detail the instructions.  Thank you.
0
Comment
Question by:samiam41
  • 7
  • 5
13 Comments
 
LVL 9

Expert Comment

by:crawfordits
Comment Utility
0
 
LVL 9

Author Comment

by:samiam41
Comment Utility
Will that work for Windows 2003 servers and XP clients?  That article talks about Windows 2000 Pro clients.
0
 
LVL 3

Expert Comment

by:JRockSolid
Comment Utility
You can copy the C:\windows\system32\GroupPolicy   Folder from a machine setup the way you want and then run GPUPDATE /force
0
 
LVL 3

Expert Comment

by:JRockSolid
Comment Utility
You would of cource want to script this with the WSHController deployment method.  Create your deployment script to copy over the folder and the script that will place the files correctly and run the GPupdate /force command.
0
 
LVL 9

Author Comment

by:samiam41
Comment Utility
JRockSolid-  Thanks for the post.  I am not sure what the WSHController deployment method is.  I will admit that I am much more of a network guy then a scripter.  If you can provide the script, I will award you the points.
0
 
LVL 9

Author Comment

by:samiam41
Comment Utility
Any one else want to contribute to this question?
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 3

Accepted Solution

by:
JRockSolid earned 500 total points
Comment Utility
OK, took some time but I got it for you.....  Hope it helps......
_______________BELOW SHOULD BE PASTED IN WHATEVER.VBS__________________
                                     This is your DEPLOYMENT Script
________________________________________________________________________
'/////////////////////////////////////////CONSTANTS   PLS Change Per Your Need
Const objMyScript = "C:\ScriptToRunOnRemotePC.vbs"
Const objResultsPCs = "C:\ResultsFromEachPC.txt"
Const objPClist = "C:\ListOfPCsNeedingGPs.txt" ' One ip or host name per line
Const ForReading = 1
Const ForWriting = 2
'/////////////////////////////////////////
Dim strComputer()
Public objError
'/////////////////////////////////////////Objects used globally
Set objController = WScript.CreateObject("WshController")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objErrorText = objFSO.OpenTextFile(objResultsPCs, ForWriting)
Call Main
'/////////////////////////////////////////
'/////////////////////////////////////////
Sub Main()
      Call GetPCs
End Sub
'/////////////////////////////////////////
'/////////////////////////////////////////Pull IP/Hostnames out of TXT file
Sub GetPCs()
x = 0
Set objTextFile = objFSO.OpenTextFile(objPClist, ForReading) '1 ip or hostname per line
      Do Until objTextFile.AtEndOfStream
            ReDim Preserve strComputer(x)
            strComputer(x)=(objTextFile.readline)
            x = x + 1
      Loop
Call TCPtest
End Sub      
'/////////////////////////////////////////
'/////////////////////////////////////////Check to see which computers in the TXT file are reachable
Sub TCPtest()
Set objShell = CreateObject("WScript.Shell")
      For z = 0 to Ubound(strComputer)
            Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer(z))
            strPingResults = LCase(objExec.StdOut.ReadAll)
            If InStr(strPingResults, "reply from") Then
                  Call ReadyReg
                  Call PushScript
            Else
                  objErrorText.WriteLine("PC : " & strComputer(z) & " Unreachable from the Network")
            End If
      Next
End Sub
'/////////////////////////////////////////
'/////////////////////////////////////////Enable Remote scripting on remote machine
Sub ReadyReg()
Set objShell = CreateObject("Wscript.Shell")
      
strKeyPath = """\\" & strComputer(z) & "\HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings"""
strCMD = "Reg Add " & strKeyPath & " /v Remote /t Reg_SZ /d 1 /f"

objShell.Run(strCMD)

End Sub
'////////////////////////////////////////
'///////////////////////////////////////Push Script to remote XP machine
Sub PushScript()
Set objRemoteScript = objController.CreateScript(objMyScript, strComputer(z))
Set objError = objRemoteScript.Error
      WScript.ConnectObject objRemoteScript, "remote_"
      objRemoteScript.Execute
      Do While objRemoteScript.Status <> 1
            WScript.Sleep 100
      Loop
      objErrorText.WriteLine("PC : " & strComputer(x) & " Script Ran on this PC Succesfully")
End Sub
'//////////////////////////////////////
'//////////////////////////////////////Remote Error Handler
Sub remote_Error()
      objErrorText.WriteLine("PC : " & strComputer(z) & " Error - Line: " & objError.Line & ", Char: " & objError.Character & " Description: " & objError.Description)
End Sub
'/////////////////////////////////////
___________________________________________________________________________
END OF DEPLOYMENT SCRIPT
___________________________________________________________________________

The Following Should be pasted in another .VBS script
It has a constant Variable that points at it from the deployment script
____________________________________________________________________________
Const strFolder = "\\ShareWhere GPOLICY Folder is at"  

Set objShell = CreateObject("Wscript.Shell")
ObjShell.run("Xcopy /E /Y " & StrFolder & " C:\Windows\System32")
ObjShell.run("GPUPDATE /force")
_____________________________________________________________________________
Double check your Constant variables at the top of the code(s)
I did not write IfExist statements for the Files so the MUST be present before hand
Especially the file that has one host name/IP addy per line ... Without that you will not be doing anything

Unfortunately, i only have one pc here at my house so maybe you can get with someone that knows VBscript to double check before you go balls to the wall with this one?
Or,,, If you have any questions or concerns you can ask me......  
If anyone else has any friendly advice for the code pls feel free
0
 
LVL 3

Expert Comment

by:JRockSolid
Comment Utility
samiam41,
I am sorry. You need to place     Public Z     right under Public objError in the deployment script.
I am at work and have time and resources to test now so i may add more updates. :)
0
 
LVL 3

Expert Comment

by:JRockSolid
Comment Utility
ALSO......
This is a known issue with the scripting host
http://support.microsoft.com/kb/319844
0
 
LVL 9

Author Comment

by:samiam41
Comment Utility
Thanks for the posts J!  I will test this out today and let you know what I find.
0
 
LVL 3

Expert Comment

by:JRockSolid
Comment Utility
If you arfe interested i have changed alot after alot of testing.

__________________________________________________________________
Option Explicit
'/////////////////////////////////////////CONSTANTS   PLS Change Per Your Need
Const objMyScript = "C:\ScriptToRunOnRemotePC.vbs"
Const objResultsPCs = "C:\ResultsFromEachPC.txt"
Const objPClist = "C:\ListOfPCs.txt" ' One ip or host name per line
Const ForReading = 1
Const ForWriting = 2
'/////////////////////////////////////////
'/////////////////////////////////////////
Dim strComputer()
Public objError
Public z
'/////////////////////////////////////////
'/////////////////////////////////////////Objects used globally
Set objController = WScript.CreateObject("WshController")
Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists(objResultsPCs) Then
            Set objErrorText = objFSO.OpenTextFile(objResultsPCs, ForWriting)
      Else
            Set objErrorText = objFSO.CreateTextFile(objResultsPCs, ForWriting)
      End If
Call Main
'/////////////////////////////////////////
'/////////////////////////////////////////
Sub Main()
      If Not objFSO.FileExists(objMyscript) Then
            MsgBox "Please edit the constant variable 'ObjMyScript'.  The current file doesnt exist."
            wscript.quit
      End If
      If Not objFSO.FileExists(objPClist) Then
            MsgBox "Please edit the constant variable 'objPClist'.  The current file does not exist."
            wscript.quit
      End If
Call GetPCs
End Sub
'/////////////////////////////////////////
'/////////////////////////////////////////Pull IP/Hostnames out of TXT file
Sub GetPCs()
x = 0
Set objTextFile = objFSO.OpenTextFile(objPClist, ForReading) '1 ip or hostname per line
      Do Until objTextFile.AtEndOfStream
            ReDim Preserve strComputer(x)
            strComputer(x)=(objTextFile.readline)
            x = x + 1
      Loop
Call TCPtest
End Sub      
'/////////////////////////////////////////
'/////////////////////////////////////////Check to see which computers in the TXT file are reachable
Sub TCPtest()
Set objShell = CreateObject("WScript.Shell")
      For z = 0 to Ubound(strComputer)
            Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer(z))
            strPingResults = LCase(objExec.StdOut.ReadAll)
            If InStr(strPingResults, "reply from") Then
                  Call ReadyReg
                  If Not err.number > 0 Then
                        Call RegWscript
                  End If
                  If Not err.number > 0 Then
                        Call PushScript
                  End If
                  If err.number > 0 Then
                        objErrorText.WriteLine("PC : " & strComputer(z) & " ERROR: " & err.number & " " & err.description)
                  End If
            Else
                  objErrorText.WriteLine("PC : " & strComputer(z) & " Unreachable from the Network")
            End If
      Next
End Sub
'/////////////////////////////////////////
'/////////////////////////////////////////- Known issue with WSH 5.2 requires this be run on most PCs before
Sub RegWscript()                                                                                'we can run the WSHController object
On Error Resume Next
Set objWMIService = getobject("winmgmts://"_
      & strComputer(z) & "/root/cimv2")
If err.description = "" Then       
' Obtain the Win32_Process class of object.
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_( _
      "Create").InParameters.SpawnInstance_
      objProgram.CommandLine = "Wscript -regserver"
      
'Execute the program now at the command line.
Set strShell = objWMIService.ExecMethod( _
      "Win32_Process", "Create", objProgram)
End If
      If Not err.description = "" Then
             objErrorText.WriteLine("PC : " & strComputer(z) & " ERROR: " & err.number & " " & err.description)
      End If
End Sub
'/////////////////////////////////////////
'/////////////////////////////////////////Enable Remote scripting on remote machine
Sub ReadyReg()
Set objShell = CreateObject("Wscript.Shell")
      
strKeyPath = """\\" & strComputer(z) & "\HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings"""
strCMD = "Reg Add " & strKeyPath & " /v Remote /t Reg_SZ /d 1 /f"

objShell.Run(strCMD)

End Sub
'////////////////////////////////////////
'///////////////////////////////////////Push Script to remote XP machine
Sub PushScript()
On Error Resume Next
Set objRemoteScript = objController.CreateScript(objMyScript, strComputer(z))
If err.description = "" Then
Set objError = objRemoteScript.Error
      WScript.ConnectObject objRemoteScript, "remote_"
      objRemoteScript.Execute
      Do While objRemoteScript.Status <> 1
            WScript.Sleep 100
      Loop

      objErrorText.WriteLine("PC : " & strComputer(z) & " Script Ran on this PC Succesfully")
End If
      If Not err.description = "" Then
             objErrorText.WriteLine("PC : " & strComputer(z) & " ERROR: " & err.description)
      End If
End Sub
'//////////////////////////////////////
'//////////////////////////////////////Remote Error Handler
Sub remote_Error()
      objErrorText.WriteLine("PC : " & strComputer(z) & " Error - Line: " & objError.Line & _
       ", Char: " & objError.Character & " Description: " & objError.Description)
End Sub
'/////////////////////////////////////
0
 
LVL 3

Expert Comment

by:JRockSolid
Comment Utility
Ok ... I have worked out all the bugs possible.  It has a nice progress/information interface.  I have done all i can do for there WSHcontroller.  If you email me at ajhenderson@bellsouth.net i can send you the scipt along with its dependencies.  I have been using it to send out a script that has the remote pcs send me an email with there Hostname in the subject.
Let me know something.
0
 
LVL 9

Author Comment

by:samiam41
Comment Utility
Sorry for the delay.  I have been out with the flu.  I will email you today.  Great work and I appreciate all of your help!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now