Pages

Tuesday, November 9, 2010

Tivoli Storage Manager Client Install Script using Powershell

Below is the Tivoli Install Script that I wrote to install, update, or configure Tivoli Storage Manager Clients. It works great but inorder to use it you have to setup a network share with a few things. All the files listed are necessary files and are shown in the picture.

  • IBM TSM Client Install Folders - The name matters and is used in the scripts. 
  • TSM Client Install Script.ps1 - Its given below. Just save to txt file.
  • dsm.opt - set with your normal server settings, values can be set that the script will replace. Example given below.
  • tsmjbbd.ini - the jornal service file. Must use or alter the one used below.

TSM Client Install Script Share
Be sure you edit the TSM Client Install Script.ps1 Configuration Parameters section for your environment. Also check that you either use your dsm.opt file or edit the example to match your environment.



TSM Client Install Script.ps1
###########################
# TSM Client Install Script
# Writen by Chris Towles - http://www.christowles.com
#
# ver 1.0 on 2010.10.25
#  
###########################

Clear-Host 

#Set Paramters based on OS Type
$os=Get-WMIObject win32_operatingsystem
if ($os.OSArchitecture -eq "64-bit") {
    #64
 $OSVersion = 64
 $api = "Api32"
}
else {
    #32
 $OSVersion = 32
 $api = "Api"
}

########  Configuration Parameters  ##########
$NodePassword = "Password" 
$NodeSchedule="DAILY_SCH"
$NodeDomain="DOMAIN"
$NodeClientOptSet="WINDOWS"
$TSMServerUser="USERNAME"
$TSMServerPassword="PASSWORD"
$CollocGroup="Colloc"
$ClientVersion="6.2.1.0"
$InstallerFolder = "\\SERVER\SHARE"
$InstallerVerFolder="IBM Tivoli Storage Manager Client V$ClientVersion - Windows x$OSVersion"
$ClientOptFile="c:\Program Files\Tivoli\TSM\baclient\dsm.opt"
$ClientDir="C:\Program Files\Tivoli\TSM\baclient"
$OptFile="dsm.opt"
$printCommands = $True #$false
###########################
############ Functions ################# function StartProcess ($FileToExecute,$Arguments,$ClientDir , $printCommandtoConsole) { $Tempfile = "$Env:TEMP\tempfile.txt" $var = New-Item $Tempfile -ItemType file -Force Write-Output "#######################################################################" if($printCommandtoConsole) { Write-Output "$FileToExecute" $Arguments } Write-Output "#---------------------------------------------------------------------#" Start-Process "$FileToExecute" -ArgumentList $Arguments -Wait -WorkingDirectory $ClientDir -RedirectStandardOutput $Tempfile -NoNewWindow Get-Content $Tempfile Remove-Item $Tempfile -Force } function InstallTSMClient{ Write-Host "Installing TSM Client $InstallerVerFolder. " $Arguments = @() $Arguments += " /i `"$InstallerFolder\$InstallerVerFolder\IBM Tivoli Storage Manager Client.msi`"" $Arguments += " RebootYesNo=`"No`"" $Arguments += " REBOOT=`"Suppress`" " $Arguments += " ALLUSERS=`"1`"" #$Arguments += ' INSTALLDIR=`"C:\Program Files\Tivoli\TSM\ `" ' $Arguments += " ADDLOCAL=`"BackupArchiveGUI,BackupArchiveWeb," + $api + "Runtime,AdministrativeCmd`" " #$Arguments += " TRANSFORMS=`"1033.mst`"" $Arguments += " /passive" StartProcess "msiexec.exe" $Arguments "$InstallerFolder\$InstallerVerFolder" $printCommands } function UninstallTSMClient { Write-Host "Unstalling TSM Client." $UninstallString = Get-UninstallCommand "IBM Tivoli Storage Manager Client" if($UninstallString -ne $null ) { $Command = $UninstallString.Split()[0] $Arguments = @() $Arguments += $UninstallString.Split()[1].Replace("/I", "/X") $Arguments += " /passive" if($Command -ne $null) { StartProcess $Command -Arguments $Arguments -ClientDir "$InstallerFolder\$InstallerVerFolder" $printCommands } } else { Write-Host "TSM Client wasn't installed." } } Function Get-TSMClientInstallVersion { $value = "PtfLevel" $key = "hklm:\\SOFTWARE\IBM\ADSM\CurrentVersion\BackupClient" $TSMVersion = (Get-ItemProperty $key $value).$value if($TSMVersion -eq $null){ Write-Host "TSM Client is not installed." } else{ Write-Host "TSM Client Version $TSMVersion is installed." } $TSMVersion } Function Get-UninstallCommand ($DisplayName) { $key = "hklm:\\SOFTWARE\Microsoft\Windows\CurrentVersion\uninstall" $value = "UninstallString" $UninstallString = $null #Search for Key $TSMKey = (Get-ChildItem $key | % { if((get-itemproperty -Path $_.PsPath) -match $DisplayName) { $_.Name} }) if( $TSMKey -ne $null) { $TSMKey = $TSMKey.Replace("HKEY_LOCAL_MACHINE\","hklm:\\") if($TSMKey -ne $null){ $UninstallString = (Get-ItemProperty $TSMKey $value).$value } } $UninstallString } function InstallTSMScheduler { Write-Host "Installing TSM Scheduler." $Arguments = @() $Arguments += "install" $Arguments += "scheduler" $Arguments += "/name:`"TSM Scheduler`"" $Arguments += "/node:" + [Environment]::MachineName $Arguments += "/password:`"$NodePassword`"" $Arguments += "/clientdir:`"$ClientDir`"" $Arguments += "/optfile:`"$ClientDir\$OptFile`"" $Arguments += "/autostart:no" $Arguments += "/startnow:no" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function UninstallTSMScheduler { Write-Host "UnInstalling TSM Scheduler." #dsmcutil.exe remove /name:"TSM Scheduler" $Arguments = @() $Arguments += "remove" $Arguments += "/name:`"TSM Scheduler`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function InstallTSMClientAcceptor{ Write-Host "Installing TSM Client Acceptor." $Arguments = @() $Arguments += "install" $Arguments += "cad" $Arguments += "/name:`"TSM Client Acceptor`"" $Arguments += "/node:" + [Environment]::MachineName $Arguments += "/password:`"$NodePassword`"" $Arguments += "/CADSCHEDNAME:`"TSM Scheduler`"" $Arguments += "/autostart:yes" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function UninstallTSMClientAcceptor{ Write-Host "Uninstalling TSM Remote Client Agent." #dsmcutil.exe remove /name:"TSM Client Acceptor" $Arguments = @() $Arguments += "remove" $Arguments += "/name:`"TSM Client Acceptor`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function InstallTSMRemoteAgent { Write-Host "Installing TSM Remote Client Agent." $Arguments = @() $Arguments += "install" $Arguments += "remoteagent" $Arguments += "/name:`"TSM Remote Client Agent`"" $Arguments += "/node:" + [Environment]::MachineName $Arguments += "/password:`"$NodePassword`"" $Arguments += "/partnername:`"TSM Client Acceptor`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function UninstallTSMRemoteAgent{ Write-Host "Uninstalling TSM Remote Client Agen." #dsmcutil.exe remove /name:"TSM Client Acceptor" $Arguments = @() $Arguments += "remove" $Arguments += "/name:`"TSM Remote Client Agent`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function InstallTSMJournal { Write-Host "Installing TSM Journal Service." $Arguments = @() $Arguments += "install" $Arguments += "journal" $Arguments += "/name:`"TSM Journal Service`"" $Arguments += "/optfile:`"$ClientDir\$OptFile`"" $Arguments += "/autostart:yes" $Arguments += "/startnow:no" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function UninstallTSMJournal{ Write-Host "Uninstalling TSM Journal Service." #dsmcutil.exe remove /name:"TSM Journal Service" $Arguments = @() $Arguments += "remove" $Arguments += "/name:`"TSM Journal Service`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function StartTSMServices { Write-Host "Restarting TSM Services on this Box." $Arguments = @() $Arguments += "stop" $Arguments += "/name:`"TSM Client Acceptor`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands $Arguments = @() $Arguments += "start" $Arguments += "/name:`"TSM Client Acceptor`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands $Arguments = @() $Arguments += "stop" $Arguments += "/name:`"TSM Journal Service`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands $Arguments = @() $Arguments += "start" $Arguments += "/name:`"TSM Journal Service`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function StopTSMServices { Write-Host "Stoping TSM Services on this Box." $Arguments = @() $Arguments += "stop" $Arguments += "/name:`"TSM Client Acceptor`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands $Arguments = @() $Arguments += "stop" $Arguments += "/name:`"TSM Journal Service`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands $Arguments = @() $Arguments += "stop" $Arguments += "/name:`"TSM Scheduler`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands $Arguments = @() $Arguments += "stop" $Arguments += "/name:`"TSM Remote Client Agent`"" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function ReplaceTSMOptFileTags ( $line ) { $line = $line.Replace("" , [Environment]::MachineName ) $line = $line.Replace("" , [Environment]::UserName ) $line = $line.Replace("" , ( Get-Date ) ) $line = $line.Replace("", ( Get-Date ) ) $line = $line.Replace("", "This Tivoli install was done by a Powershell script to handle the TSM Client Install and Client setup. " + "The installer location was from $InstallerFolder" ) $line } function InstallDSMOptFile { #copy dsm.opt file Write-Host "Copying dsm.opt File to host from $InstallerFolder" Copy-Item "$InstallerFolder\$OptFile" "$ClientDir\$OptFile" #Edit the Dsm.opt File with notes $OptFileContent = Get-Content $ClientDir\$OptFile $OptFileContent | Foreach-Object { ReplaceTSMOptFileTags $_ } | Set-Content $ClientDir\$OptFile Start-Process notepad $ClientDir\$OptFile -Wait } function Get-TSMServices { $Arguments = @() $Arguments += "list" StartProcess "$ClientDir\dsmcutil.exe" $Arguments $ClientDir $printCommands } function CreateTSMNode { Write-Host "Create TSM Node " + ([Environment]::MachineName) $Arguments = @() $Arguments += "-id=$TSMServerUser" $Arguments += "-password=`"$TSMServerPassword`"" $Arguments += "register" $Arguments += "node" $Arguments += [Environment]::MachineName $Arguments += $NodePassword $Arguments += "domain=$NodeDomain" StartProcess "$ClientDir\dsmadmc.exe" $Arguments $ClientDir $printCommands } function InstallJournalOptFile { #copy tsmjbbd.ini file Write-Host "Copying tsmjbbd.ini File to host from $InstallerFolder" $JornalOptFile = "tsmjbbd.ini" Copy-Item "$InstallerFolder\$JornalOptFile" "$ClientDir\$JornalOptFile" #Edit the File $JornalOptFileContent = Get-Content $ClientDir\$JornalOptFile $LocalDriveLetters = Get-WmiObject win32_logicaldisk -computername . | where {$_.description -contains "Local Fixed Disk"} | ForEach-Object { $_.deviceID } Write-Host "The following are the Local Drives: $LocalDriveLetters" #find the section of file we need for each local drive and copy it $DriveSection = @() $NewDriveSection = @() $copyline = $false foreach($line in $JornalOptFileContent){ if($line -match ""){ $copyline = $true } elseif($line -match ""){ $copyline = $false } elseif( $copyline ) { $DriveSection += $line.TrimStart(";") } } #create the section for Local drives Foreach($drive in $LocalDriveLetters){ Foreach($line in $DriveSection){ $NewDriveSection += $line.Replace("" , $drive ) } } #Create the new File $NewJornalOptFile = @() foreach($line in $JornalOptFileContent){ if($line -match ""){ $NewJornalOptFile += $line.Replace("" , $LocalDriveLetters ) $NewJornalOptFile += $NewDriveSection } else { $NewJornalOptFile += $line } } Write-Host "$JornalOptFile Configured and Installed." Set-Content $ClientDir\$JornalOptFile ($NewJornalOptFile) #Start-Process notepad $ClientDir\$JornalOptFile -Wait } function Run-DSMCIncremental { Write-Host "Starting Tivoli Incrmental Backup." $Arguments = @() $Arguments += "incr" Start-Process "$ClientDir\dsmc.exe" -WorkingDirectory $ClientDir -ArgumentList $Arguments } function AssociateTSMNodeWithClientOptSet { Write-Host "Associating TSM Node with ClientOpt $NodeClientOptSet." $Arguments = @() $Arguments += "-id=$TSMServerUser" $Arguments += "-password=`"$TSMServerPassword`"" $Arguments += "update" $Arguments += "node" $Arguments += [Environment]::MachineName $Arguments += $NodePassword $Arguments += "domain=$NodeDomain" $Arguments += "cloptset=`"$NodeClientOptSet`"" StartProcess "$ClientDir\dsmadmc.exe" $Arguments $ClientDir $printCommands } function AssociateTSMNodeWithSchedule { Write-Host "Associating TSM Node with Schedule $NodeSchedule." $Arguments = @() $Arguments += "-id=$TSMServerUser" $Arguments += "-password=`"$TSMServerPassword`"" $Arguments += "define" $Arguments += "association" $Arguments += $NodeDomain $Arguments += $NodeSchedule $Arguments += [Environment]::MachineName StartProcess "$ClientDir\dsmadmc.exe" $Arguments $ClientDir $printCommands } function AssociateTSMNodeWithCollocationGroup { Write-Host "Associating TSM Node With CollocationGroup $CollocGroup." $Arguments = @() $Arguments += "-id=$TSMServerUser" $Arguments += "-password=`"$TSMServerPassword`"" $Arguments += "define" $Arguments += "COLLOCMember" $Arguments += $CollocGroup $Arguments += [Environment]::MachineName StartProcess "$ClientDir\dsmadmc.exe" $Arguments $ClientDir $printCommands } ########## Type of Installs ###################### function InstallTSMNode { $CommandOuput = @() ########## Tivoli Client Side Commands ############## $CommandOuput += InstallTSMClient $CommandOuput += InstallDSMOptFile ########## Tivoli Server Side Commands ############## $CommandOuput += CreateTSMNode $CommandOuput += AssociateTSMNodeWithClientOptSet $CommandOuput += AssociateTSMNodeWithCollocationGroup $CommandOuput += AssociateTSMNodeWithSchedule ########## Tivoli Client Side Commands ############## $CommandOuput += InstallTSMClientAcceptor $CommandOuput += InstallTSMRemoteAgent $CommandOuput += InstallTSMScheduler $CommandOuput += InstallTSMJournal $CommandOuput += InstallJournalOptFile $CommandOuput += Get-TSMServices ########## Tivoli Start Local Services ############## $CommandOuput += StartTSMServices ########## Run the first backup ##################### $CommandOuput += Run-DSMCIncremental $CommandOuput } function UninstallTSMNode { $CommandOuput = @() $CommandOuput += StopTSMServices $CommandOuput += UninstallTSMJournal $CommandOuput += UninstallTSMRemoteAgent $CommandOuput += UninstallTSMScheduler $CommandOuput += UninstallTSMClientAcceptor $CommandOuput += UninstallTSMClient #Send Email that Uninstall was done } ######################################### #create Log file $logfile = "$Env:TEMP\TsmScriptInstall.txt" $var = New-Item $logfile -ItemType file -Force $CommandResults = @() $CommandResults += "TSM Install Log: " + (Get-Date ) $CommandResults += UninstallTSMNode $CommandResults += InstallTSMNode #Get-TSMClientInstallVersion $CommandResults ########## Log ############## Add-Content $logfile ( $CommandResults ) Start-Process notepad $logfile -Wait Remove-Item $logfile #Delete the log; it has passwords stored in it.

TSM Client Dsm.opt File
*******************************************************
* NKU TSM Windows Option File        
*        
* Server name: 
* Setup By: 
*  Setup When:  
* Last Modified: 
*
* Notes: 
*
*******************************************************

PASSWORDACCESS GENERATE
MANAGEDSERVICES WEBCLIENT SCHEDULE

TCPSERVERADDRESS TSM1.NKU.EDU

SNAPSHOTPROVIDERFS VSS

QUERYSCHEDPERIOD 6
SCHEDMODE POLLING
SCHEDLOGNAME "c:\program files\tivoli\tsm\baclient\dsmsched.log"


* Wraps Logs to stop their size in mb
ERRORLOGMAX 90
SCHEDLOGMAX 90


EXCLUDE.BACKUP "c:\program files\tivoli\tsm\baclient\dsmsched.*"

EXCLUDE.BACKUP "*:\microsoft uam volume\...\*" 
EXCLUDE.BACKUP "*:\microsoft uam volume\...\*.*" 
EXCLUDE.BACKUP "*:\...\EA DATA. SF" 
EXCLUDE.BACKUP "*:\IBMBIO.COM" 
EXCLUDE.BACKUP "*:\IBMDOS.COM" 
EXCLUDE.BACKUP "*:\IO.SYS" 
EXCLUDE.BACKUP "*:\...\system32\config\...\*" 
EXCLUDE.BACKUP "*:\...\system32\Perflib*.dat" 
EXCLUDE.BACKUP "*:\...\system32\dhcp\...\*" 
INCLUDE.BACKUP "*:\...\system32\dhcp\backup\...\*" 
EXCLUDE.BACKUP "*:\...\system32\dns\...\*" 
INCLUDE.BACKUP "*:\...\system32\dns\backup\...\*" 
EXCLUDE.ARCHIVE "*:\microsoft uam volume\...\*" 
EXCLUDE.ARCHIVE "*:\microsoft uam volume\...\*.*" 
EXCLUDE.ARCHIVE "*:\...\EA DATA. SF" 
EXCLUDE.ARCHIVE "*:\IBMBIO.COM" 
EXCLUDE.ARCHIVE "*:\IBMDOS.COM" 
EXCLUDE.ARCHIVE "*:\IO.SYS" 
EXCLUDE.ARCHIVE "*:\...\system32\config\...\*" 
EXCLUDE.ARCHIVE "*:\...\system32\Perflib*.dat" 
EXCLUDE.ARCHIVE "*:\...\system32\dhcp\...\*" 
INCLUDE.ARCHIVE "*:\...\system32\dhcp\backup\...\*" 
EXCLUDE.ARCHIVE "*:\...\system32\dns\...\*" 
INCLUDE.ARCHIVE "*:\...\system32\dns\backup\...\*" 
EXCLUDE.DIR "*:\System Volume Information" 
EXCLUDE.DIR "*:\...\Temporary Internet Files" 
EXCLUDE.DIR "*:\Recycled" 
EXCLUDE.DIR "*:\Recycler" 
EXCLUDE.DIR "*:\$Recycle.Bin" 

TSM Journal Service INI - tsmjbbd.ini
[JournaledFileSystemSettings]
JournalDBSize=0x00100000
; Default journal db size - Allows journal to grow, limited only by space available
NotifyFilter=0x00000117
; What events to monitor ; File & Dir Name, Size, Attrib, Last Write, Security
NotifyBufferSize=0x00008000
DirNotifyBufferSize=0x00004000
JournaledFileSystems=

;
;[JournaledFileSystemSettings.\]
;JournalDBSize=0x00000000
;JournalDir=C:\Program Files\Tivoli\TSM\baclient\Journal
;NotifyFilter=0x00000117
;

[JournalSettings]
Errorlog=jbberror.log
JournalDir=C:\Program Files\Tivoli\TSM\baclient\Journal

[JournalExcludeList]
%SystemRoot%\System32\Config\*
%SystemDrive%\Adsm.Sys\*
%TEMP%\*
%TMP%\*
%USERPROFILE\*\index.dat
*\System Volume Information\*
*\Recycle*\*
*\*.jbbdb
*\*\obi.tsm
*\*\obh.tsm
*\*\obd.tsm
*\tsmlvsacache
*\tsmlvsacache\*
*\pagefile.sys
*\*.crmlog
*\hiberfil.sys
%SystemRoot%\csc\*
%SystemRoot%\System32\DTCLog\MSDTC.LOG
%SystemRoot%\netlogon.chg
%SystemRoot%\schedlgu.txt
%SystemRoot%\registration\*.clb
%WINDIR%\debug\*
%WINDIR%\system32\config\*
%TEMP%\*
%TMP%\*
%SystemDrive%\Documents and Settings\NetShowServices\ntuser.dat
%SystemDrive%\Documents and Settings\NetShowServices\Local Settings\Application Data\Microsoft\Windows\UsrClass.dat
%USERPROFILE%\ntuser.dat
%USERPROFILE%\Local Settings\Application Data\Microsoft\Windows\UsrClass.dat
*\microsoft uam volume\*
*\microsoft uam volume\*
*\IBMBIO.COM*
*\IBMDOS.COM*
*\MSDOS.SYS
*\IO.SYS
%WINDIR%\system32\Perflib*.dat
%WINDIR%\system32\dhcp\*
%WINDIR%\system32\dhcp\backup*\*
%WINDIR%\system32\dns*\*
%WINDIR%\system32\dns\backup\*
*\System Volume Information*
*\*Temporary Internet Files*
*\Recycled*
*\Recycler*

1 comment:

  1. Hello

    Thank you for the script.

    I have a question tho. From where are you getting this:
    $UninstallString = Get-UninstallCommand "IBM Tivoli Storage Manager Client"
    and
    Function Get-TSMClientInstallVersion

    Specifically the Gets.
    The script always return
    Write-Host "TSM Client wasn't installed."
    Because it doesn't know what Get-UninstallCommand is.

    Atleast i cant see it.

    Thank you.

    ReplyDelete

Please leave a comment; someone, anyone!