samiam41
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.
https://www.experts-exchange.com/questions/20805042/Is-it-possible-to-Export-the-Local-Group-Policy-Settings.html
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\GroupP olicy 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.
ASKER
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.
ASKER
Any one else want to contribute to this question?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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. :)
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. :)
ASKER
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
'///////////////////////// ////////// //////CONS TANTS 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
'///////////////////////// ////////// //////
'///////////////////////// ////////// //////Obje cts used globally
Set objController = WScript.CreateObject("WshC ontroller" )
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
If objFSO.FileExists(objResul tsPCs) Then
Set objErrorText = objFSO.OpenTextFile(objRes ultsPCs, ForWriting)
Else
Set objErrorText = objFSO.CreateTextFile(objR esultsPCs, ForWriting)
End If
Call Main
'///////////////////////// ////////// //////
'///////////////////////// ////////// //////
Sub Main()
If Not objFSO.FileExists(objMyscr ipt) Then
MsgBox "Please edit the constant variable 'ObjMyScript'. The current file doesnt exist."
wscript.quit
End If
If Not objFSO.FileExists(objPClis t) 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(objPCl ist, ForReading) '1 ip or hostname per line
Do Until objTextFile.AtEndOfStream
ReDim Preserve strComputer(x)
strComputer(x)=(objTextFil e.readline )
x = x + 1
Loop
Call TCPtest
End Sub
'///////////////////////// ////////// //////
'///////////////////////// ////////// //////Chec k to see which computers in the TXT file are reachable
Sub TCPtest()
Set objShell = CreateObject("WScript.Shel l")
For z = 0 to Ubound(strComputer)
Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer(z))
strPingResults = LCase(objExec.StdOut.ReadA ll)
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_P rocess")
Set objProgram = objProcess.Methods_( _
"Create").InParameters.Spa wnInstance _
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
'///////////////////////// ////////// //////
'///////////////////////// ////////// //////Enab le Remote scripting on remote machine
Sub ReadyReg()
Set objShell = CreateObject("Wscript.Shel l")
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 (objMyScri pt, 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
'///////////////////////// ////////// //
__________________________
Option Explicit
'/////////////////////////
Const objMyScript = "C:\ScriptToRunOnRemotePC.
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
'/////////////////////////
'/////////////////////////
Set objController = WScript.CreateObject("WshC
Set objFSO = CreateObject("Scripting.Fi
If objFSO.FileExists(objResul
Set objErrorText = objFSO.OpenTextFile(objRes
Else
Set objErrorText = objFSO.CreateTextFile(objR
End If
Call Main
'/////////////////////////
'/////////////////////////
Sub Main()
If Not objFSO.FileExists(objMyscr
MsgBox "Please edit the constant variable 'ObjMyScript'. The current file doesnt exist."
wscript.quit
End If
If Not objFSO.FileExists(objPClis
MsgBox "Please edit the constant variable 'objPClist'. The current file does not exist."
wscript.quit
End If
Call GetPCs
End Sub
'/////////////////////////
'/////////////////////////
Sub GetPCs()
x = 0
Set objTextFile = objFSO.OpenTextFile(objPCl
Do Until objTextFile.AtEndOfStream
ReDim Preserve strComputer(x)
strComputer(x)=(objTextFil
x = x + 1
Loop
Call TCPtest
End Sub
'/////////////////////////
'/////////////////////////
Sub TCPtest()
Set objShell = CreateObject("WScript.Shel
For z = 0 to Ubound(strComputer)
Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer(z))
strPingResults = LCase(objExec.StdOut.ReadA
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
End If
Else
objErrorText.WriteLine("PC
End If
Next
End Sub
'/////////////////////////
'/////////////////////////
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_P
Set objProgram = objProcess.Methods_( _
"Create").InParameters.Spa
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
End If
End Sub
'/////////////////////////
'/////////////////////////
Sub ReadyReg()
Set objShell = CreateObject("Wscript.Shel
strKeyPath = """\\" & strComputer(z) & "\HKLM\SOFTWARE\Microsoft\
strCMD = "Reg Add " & strKeyPath & " /v Remote /t Reg_SZ /d 1 /f"
objShell.Run(strCMD)
End Sub
'/////////////////////////
'/////////////////////////
Sub PushScript()
On Error Resume Next
Set objRemoteScript = objController.CreateScript
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
End If
If Not err.description = "" Then
objErrorText.WriteLine("PC
End If
End Sub
'/////////////////////////
'/////////////////////////
Sub remote_Error()
objErrorText.WriteLine("PC
", 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.
Let me know something.
ASKER
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!