I found a script on EE from RobSampson that is listed below that I am able to use but have a few questions.
The script is working as far as adding the group to the power users local group. In the code below the group is paul.
But when I run the script I get the error below and no results file is created.
Line 31: Set objOutputFile = objFSO.CreateTextFile(strO
Is there a way to get it to show results so I know if the group was added to all the servers in the list? I need to run it remotely on 187 servers. Is there a way to specify a different domain than the one you are logged in with? Like Domain2\paul instead of paul (domain1\paul).
The servers are in several different domains but the account I am using has access to all of them.
strInputFile = "Computers.txt"
strOuputFile = "Results.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Set objNetwork = CreateObject("WScript.Network")
Set objUser = GetObject("WinNT://" & objNetwork.UserDomain & "/paul")
strResults = "Adding " & objNetwork.UserDomain & "/paul to local Power Users group"
strResults = strResults & VbCrLf & "========================================================================"
Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
While Not objInputFile.AtEndOfStream
strComputer = objInputFile.ReadLine
If Ping(strComputer) = True Then
Set objGroup = GetObject("WinNT://" & strComputer & "/Power Users")
On Error Resume Next
If Err.Number = 0 Then
strResults = strResults & VbCrLf & strComputer & ": Successfully added"
strResults = strResults & VbCrLf & strComputer & ": Failed to add: " & Err.Number & " - " & Err.Description
On Error GoTo 0
Set objGroup = Nothing
strResults = strResults & VbCrLf & strComputer & ": Unable to ping"
Set objInputFile = Nothing
Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True)
Set objOutputFile = Nothing
Set objFSO = Nothing
Set objNetwork = Nothing
MsgBox "Finished. Please see " & strOutputFile
Dim objShell, boolCode
Set objShell = CreateObject("WScript.Shell")
boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
If boolCode = 0 Then
Ping = True
Ping = False