Link to home
Start Free TrialLog in
Avatar of samiam41
samiam41Flag for United States of America

asked on

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

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.
Avatar of crawfordits
crawfordits

Avatar of samiam41

ASKER

Will that work for Windows 2003 servers and XP clients?  That article talks about Windows 2000 Pro clients.
You can copy the C:\windows\system32\GroupPolicy   Folder from a machine setup the way you want and then run GPUPDATE /force
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.
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.
Any one else want to contribute to this question?
ASKER CERTIFIED SOLUTION
Avatar of JRockSolid
JRockSolid

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
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. :)
ALSO......
This is a known issue with the scripting host
http://support.microsoft.com/kb/319844
Thanks for the posts J!  I will test this out today and let you know what I find.
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
'/////////////////////////////////////
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.
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!