Ying Li at myITforum.com

PowerShell & System Center

To Install DST Patches Remotly on Multiple Servers

We have a lot of “non standard” servers for whatever reasons. In order to facilitate the DST patch push. I put together an Ad Hoc script to push DST patch to server otherwise can’t be pushed through SMS or Opsware.

First I download psexec.exe from http://www.microsoft.com/technet/sysinternals/utilities/psexec.mspx

Then I run the following VBS script on my computer. What this script does is to copy the “DST” folder to the targeted servers. Then I will use psexec to kick off the dst.bat file on each target server.



On Error Resume Next
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set InputFile = oFSO.OpenTextFile("C:\MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
    sSourceFolder = "C:\DST"
    sDestFolderName= "DST"
    sDestFolder = "\\" & strComputer & "\C$\" & sDestFolderName
    oFSO.CopyFolder sSourceFolder, sDestFolder
Set objShell = CreateObject("WScript.Shell")
objShell.Run("%comspec% /K psexec.exe  \\" & strComputer & " -i C:\dst\dst.bat"), 1, True


Here is the contents of DST folder:



TimeZoneupd.reg (NT)

TimeZoneUpdate.exe (NT)



The OSVER.EXE is from Bill Stewart's Site. OSVER allows a batch file to perform operating system platform checking. It can differentiate between Windows 95, Windows 98, Windows Me, Windows NT 4.0, Windows 2000, Windows XP, and Windows Server 2003.

 I use Windows OS detection script by Doc Rice as a template and modified it to create my dst.bat file. What it does is to check the Windows OS version on the remote targets and then install the applicable patch.



@echo off

for /f "tokens=*" %%i in ('c:\dst\osver.exe') do set windowsversion=%%i

echo This operating system is %windowsversion%.

if "%windowsversion%" == "Windows NT 4.0" goto windowsnt
if "%windowsversion%" == "Windows 2000" goto windows2000
if "%windowsversion%" == "Windows Server 2003" goto windows2003

call c:\dst\TimeZoneUpdate.exe
goto end

call C:\dst\Windows2000-KB931836-x86-ENU.EXE /quiet /norestart
goto end

call c:\dst\WindowsServer2003-KB931836-x86-ENU.exe /quiet /norestart
goto end



Thanks Bill Stewart and Doc Rice for their contribution!



No Comments