Another upate, I realised that if I ran the script more than once I would loose the backuo copy I created.
This isnt great beacuse I have to go back and put it all right again if anything fails, so ive added the date & time to the copy.
However that created another problem, I cant tell power shell to open a file that I dont have the name for so this is what I ended up with:
$servers = get-content c:\joe\tsmlist.txt
$Date = (Get-Date -format “dd-MM-yyyy_HH-mm-ss”)
foreach ($server in $servers){
$server
$file = copy-item “\\$server\c$\Program Files\Tivoli\TSM\baclient\dsm.opt” “\\$server\c$\Program Files\Tivoli\TSM\baclient\dsm-$Date.opt”
$file = copy-item “\\$server\c$\Program Files\Tivoli\TSM\baclient\dsm.opt” “\\$server\c$\Program Files\Tivoli\TSM\baclient\dsm-OLD.opt”
$file = get-content “\\$server\c$\Program Files\Tivoli\TSM\baclient\dsm-OLD.opt” |
foreach-object {$_ -replace ‘EXCLUDE\.DIR “C:\\Documents and Settings”‘, “”} |
set-content “\\$server\c$\Program Files\Tivoli\TSM\baclient\dsm.opt”
Restart-Service -InputObject $(get-service -ComputerName $server -Name “TSM Client Scheduler”)
}