Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Permissions to Instantiate objects remotely?

Reply
Thread Tools Display Modes

Permissions to Instantiate objects remotely?

 
 
Rich
Guest
Posts: n/a

 
      01-22-2009
Does anyone know if it possible to instantiate objects remotely using vbs or
powershell? Right now I am trying to use psexec to execute a batch file that
calls a local script on a server to deploy patches using the WSUS client.
The problem is that when I try to use this object Set objDownloader =
objSession.CreateUpdateDownloader() and some of the others I get access
denied. But if remote desktop onto the server it works without any
permission problems. With psexec I have tried the -u parameter so it should
not be using impersonation but the domain admin creds. I have a hole in my
knowledge on using objects like this remotely so any help or experiences
would be helpful. Thanks.



Set fso = CreateObject("Scripting.FileSystemObject")
Set objAutomaticUpdates = CreateObject("Microsoft.Update.AutoUpdate")
Set objComputer = CreateObject("Shell.LocalMachine")

Wscript.Echo "Server name: " & objComputer.MachineName

' Search for updates
objAutomaticUpdates.EnableService
objAutomaticUpdates.DetectNow

Set objSession = CreateObject("Microsoft.Update.Session")
Set objSearcher = objSession.CreateUpdateSearcher()
Set objResults = objSearcher.Search("IsInstalled=0 and Type='Software'")
'Set objResults = objSearcher.Search("Type='Software'")
Set colUpdates = objResults.Updates


' List out updates that were found.
For each objUpdates in colUpdates
Wscript.echo objUpdates
objPatchRecordset.AddNew
objPatchRecordset("Name") = objComputer.MachineName
objPatchRecordset("Patches") = objUpdates
objPatchRecordset.Update
Next


Wscript.Quit

' Download Updates if needed
Set objUpdatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
intUpdateCount = 0
For i = 0 to colUpdates.Count - 1
intUpdateCount = intUpdateCount + 1
Set objUpdate = colUpdates.Item(i)
objUpdatesToDownload.Add(objUpdate)
Next

If intUpdateCount = 0 Then
WScript.Echo "No Patches to Install!"
WScript.Quit
Else
Set objDownloader = objSession.CreateUpdateDownloader()
objDownloader.Updates = objUpdatesToDownload
objDownloader.Download()

' Install updates
Set objInstaller = objSession.CreateUpdateInstaller()
objInstaller.Updates = objUpdatesToDownload
Set installationResult = objInstaller.Install()

' Reboot server if needed
Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")
If objSysInfo.RebootRequired Then
Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonat e,(Shutdown)}!\\localhost\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next
End If
End If

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default permissions on new contact objects Mike Eastaugh Active Directory 1 10-23-2006 02:48 PM
User objects not inheriting permissions H_stressed Active Directory 2 03-17-2006 07:15 PM
edit permissions remotely Perry Diels Server Networking 0 07-04-2005 09:05 PM
Find where objects are assigned permissions? - Server Networking 0 07-07-2004 09:36 PM
Find where objects are assigned permissions? - Active Directory 0 07-07-2004 09:36 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59