Solved

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

Posted on 2006-10-30
13
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
13 Comments
 
LVL 9

Author Comment

by:samiam41
ID: 17836988
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
ID: 17839149
You can copy the C:\windows\system32\GroupPolicy   Folder from a machine setup the way you want and then run GPUPDATE /force
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:JRockSolid
ID: 17839169
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
ID: 17842202
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
ID: 17843661
Any one else want to contribute to this question?
0
 
LVL 3

Accepted Solution

by:
JRockSolid earned 500 total points
ID: 17847384
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
ID: 17849283
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
ID: 17849665
ALSO......
This is a known issue with the scripting host
http://support.microsoft.com/kb/319844
0
 
LVL 9

Author Comment

by:samiam41
ID: 17849940
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
ID: 17861139
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
ID: 17894462
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
ID: 17906968
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

623 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