Jump to content
Sign in to follow this  
xCROv

(SOLVED) Specify credentials when using remote registry

Recommended Posts

xCROv

I am trying to update the WSUS AUOption on a list of computers by IP. I have the code for this that functions but it requires me to have already made a connection through regedit to this computer and that isn't helping much since I might as well import the changes there if I have to do that. I'm wondering if anyone has any ideas for validating a local admin credentials via another method. Posted my code below. 

 

#RequireAdmin

#include <File.au3>
#include <MsgBoxConstants.au3>

Local $aArray = FileReadToArray("C:\Users\coconner\Desktop\IPlist.txt")

Local $iLineCount = @extended

If @error Then
    MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
Else
    For $i = 0 To $iLineCount - 1 ; Loop through the array. UBound($aArray) can also be used.
        MsgBox($MB_SYSTEMMODAL, "", $aArray[$i]) ; Display the contents of the array.
        RegWrite("\\" & $$aArray[$i] & "\" & "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "AUOptions", "REG_DWORD", "00000004")
    Next
EndIf

 

Edited by xCROv

Share this post


Link to post
Share on other sites
JLogan3o13

You are using a single domain account that has administrative rights on all the machines, correct? So you can compile your script and Run it as that account. Or am I misunderstanding your meaning?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
xCROv
Just now, JLogan3o13 said:

You are using a single domain account that has administrative rights on all the machines, correct? So you can compile your script and Run it as that account. Or am I misunderstanding your meaning?

These are non-domain joined computers (I know...). I am doing WSUS through registry edits at the moment and working towards getting them on a domain at a later date. My issue is that they are currently set to AUOption value 3 and that means they dont install updates automatically. I need to edit the registry value to 4 for them to actually install the WSUS updates. This is on about 150 computers so I would rather not have to do it by hand. The script above works for stepping through a array and making a connection, just having issues with validating the local credentials so that I have the permissions to write to the registry. If I connect to the computer using regedit and then run the script it does everything as expected.

Share this post


Link to post
Share on other sites
JLogan3o13

Are they bound in any way (same workgroup, homegroup, etc.), or simply a bunch of computers on the same segment?

Edit: and do you at least have the same Admin credentials set on each?

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
xCROv

All have the same admin credentials. They are all in WORKGROUP. 

I was using RunAsWait() with the following but am not seeing the changes on the computer side.

RunAsWait("USERNAME","WORKGROUP","PASSWORD", 0, "\\" & $aArray[$i] & "\c$\Windows\System32\cmd.exe" & " /c " & '%SystemRoot%\System32\reg.exe add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v AUOptions /t REG_DWORD /d 4 /f')

 

Share this post


Link to post
Share on other sites
bernd670

Hello,

you can use psexec from pstools to run a command on a remote computer. The code in your last post run the remote cmd on your local computer.


greetings
bernd


I hacked 127.0.0.1 -> pcfred6.gif

Share this post


Link to post
Share on other sites
AdamUL

I would compile the regwrites to a script, and then have a local script to uses PAExec to execute it on the remote computers. 

 

Adam

  

Share this post


Link to post
Share on other sites
xCROv

psexec is probably the best route. Will probably go down that route. Thanks!

Share this post


Link to post
Share on other sites
xCROv

For those of you reading from the future. Using PSExec I ran with the following.

You need to change %username% and %password% with your credentials if you need them.

psexec -d -u %USERNAME% -p %PASSWORD% -n 30 -s @C:\IPList.txt cmd /c "%SystemRoot%\System32\reg.exe add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v AUOptions /t REG_DWORD /d 4 /f"

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×