We then use this variable when we call the Search method from the Searcher object. The results are seen here:Īfter we have found the update we wish to install, we copy the updateID and assign it to the $UpdateID variable. #OFFICE 2011 FOR MAC UPDATE DOWNLOAD PROGRESSE PLUS#We then tab over by using the “`t” and print out the title of the update as well by concatenating it via the plus sign (+). We have added the ForEach-Object cmdlet to allow us to return the updateID property from the Update Identity object. $results = $arch(“Type=’software’ AND IsInstalled = 0”)įorEach-Object #OFFICE 2011 FOR MAC UPDATE DOWNLOAD PROGRESSE SOFTWARE#To easily retrieve updateIDs for software updates that are not yet installed, we can use the ListSoftwareUpdatesNotInstalled.ps1 script (this script is a revision of the ListSoftwareUpdates.ps1 script we looked at yesterday): $Searcher = New-Object -ComObject #OFFICE 2011 FOR MAC UPDATE DOWNLOAD PROGRESSE INSTALL#If we want to install a specific update, we can use the updateID property from the Update Identity object. To install a software update, we need to first search for the update, add the retrieved update to the update collection, download the update, and finally install the update. #OFFICE 2011 FOR MAC UPDATE DOWNLOAD PROGRESSE CODE#The code that creates the Session object is seen here: $Session = New-Object -ComObject Also known as the IUpdateSession interface, it is documented on MSDN. It also is created with the New-Object cmdlet. This object, like the other two objects, begins with Microsoft.Update. The next object we need to create is the Session object. This is seen here: $Searcher = New-Object -ComObject We store the returned Searcher object in the $Searcher variable. To create the Searcher object, we use the New-Object cmdlet with the –ComObject parameter and supply the Program ID of. The object (also known as the IUpdateSearcher interface) is documented on MSDN. Next we need to create the Searcher object. We store the returned UpdateColl object in the $UpdateCollection variable as shown here: $UpdateCollection = New-Object -ComObject The pattern for creating these objects is seen here: $VariableToHoldObject = New-Object –ComObject ProgramIDOFTheComObject To create the UpdateColl object, we use the New-Object cmdlet and specify the –ComObject parameter and use the program ID. This object is known as the IUpdateCollection interface and it is documented on MSDN. The first thing we need to do is to create an instance of the object. $Downloader = $Session.CreateUpdateDownloader() $UpdateCollection.Add($Updates.Item(0)) | out-null $Result = $Searcher.Search(“UpdateID=’$updateID'”) Today’s script is called InstallSoftwareUpdate.ps1 and is seen here (a VBScript version of today’s script can be seen in the Script Center Script Repository): $UpdateCollection = New-Object -ComObject #OFFICE 2011 FOR MAC UPDATE DOWNLOAD PROGRESSE WINDOWS#The Windows PowerShell getting started page has basic information for learning about Windows PowerShell and about downloading Windows PowerShell. For information about manually configuring Windows Update on workstations, refer to this page. There is also a good collection of VBScripts that use the Windows Update API in the Script Center Script Repository. The Windows Update API is documented on MSDN. This week we will be looking at using the Windows Update API to work with Windows Update. So you want to be able to search for an update, download the update, and install the update? No problem. Looks cold luckily I am sipping a cup of Constant Comment tea and listening to the Kentucky Headhunters on my Zune. It looks pretty from my office windows, and the neighbors are in the street with their various snow implements. It’s a snow day! Woo Hoo! Hey, wait a minute, I work from home, so not much of a snow day after all. Well, we are snowed in down here in Charlotte today. Surely you have a better plan than that? I mean, you are after all the Microsoft Scripting Guy, not the Microsoft Talks the User Through the GUI Guy. However, what happens when I determine the update has not been applied? Am I supposed to call the user and talk them through connecting to the Microsoft Update site and choosing the appropriate update? That may work for one or two users, but it does not scale very well. Hey, Scripting Guy! Reporting on whether a Windows Update is installed or not is pretty cool.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |