Jump to content

Object Create, Windows Updates and remote logon


Recommended Posts

Ok, i've been struggling with this problem for close to 3 days now (day and night). I'm really new to scripting in AutoIT and have been asked to look at something for work.

I am trying to connect to a number of servers from an XP workstation logged in as myself. Here is a sample of the code i'm using:

$Username = (InputBox("Login", "Please enter a username","", "", 200, 120))
$Password = (InputBox("Security Check", "Enter your password.", "", "*", 200, 120))

$oSession = ObjCreate("Microsoft.Update.Session", $host, $Username, $password) ; <-------------Problem area
;$oSession = ObjCreate("Microsoft.Update.Session", $host, $host & "\" & $Username, $password) ; <-------------I've also tried this but it didnt work
$oSearcher = $oSession.CreateUpdateSearcher()

$iTotal = $oSearcher.GetTotalHistoryCount()
ConsoleWrite("Total history events: " & $iTotal & @CRLF)
$oHistoryColl = $oSearcher.QueryHistory(0, $iTotal)
For $iHistory In $oHistoryColl
FileWrite("Full_History\" & $host & "_FullHistory.txt", $iHistory.Title & @CRLF)
FileWrite("Full_History\" & $host & "_FullHistory.txt", StringRegExpReplace($iHistory.Date, "([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})", "\1/\2/\3 \4:\5:\6") & @CRLF & @CRLF)

Next

Unfortunately, this won't work unless i am logged into the XP workstation with exactly the same credentials that the server uses. This is causing a head ache because no one should actually be logging onto a w/s as the Administrator. I just want to know why it's not passing through my $username and $password and giving me the results i need when i am logged into my workstation as myself.

Any help would be really appriciated.

Thanks

Edited by Archie
Link to comment
Share on other sites

After looking at a few different sites, I'm seeing that you can specify a computer name to have the object run on remotely, but I'm not seeing where you can specify a username/password...

If your account has admin privileges, have you tried just omitting the username/password parameters from your ObjCreate? Or maybe tried putting a copy of the script without them on a remote computer and executing it with PSExec?

Referenced sites:

http://msdn.microsoft.com/en-us/library/aa387288%28v=VS.85%29.aspx

("The Windows Update Agent (WUA) API can be used by a user on a remote computer or by an application that is running on a remote computer. However, the remote user or application must have administrator privileges.")

http://technet.microsoft.com/en-us/library/ee692834.aspx#ELAA

http://blogs.technet.com/heyscriptingguy/archive/2005/08/24/how-can-i-determine-when-the-last-patch-from-windows-update-was-applied.aspx

Link to comment
Share on other sites

Hi exodius,

Thanks for the reply. It does work remotely as long as i log into the XP machine using the Administrator account (and providing the password is the same as that on the server). So yes, i could create user accounts on all the servers with admin privilages and that would let the script run. The thing is, my boss wants the ability to run these reports and he is in no way technical, so giving him admin privilages is probably not the best idea.

Reading through the AutoIT help, it does look like i should be able to pass through a username and password (as long as it is in the server\username format) but for some reason, that isn't working. i dont mind giving my boss the admin password but resetting his local machine's admin password to the same as the servers and getting him then to log out and log in as the local admin everytime he wants to run a report seems like a really long winded way of going about it.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...