Cognos Express TM1 Powershell recycle script

Cognos Express TM1 Powershell recycle script

by Darek Danielewski

Cognos Express TM1 Powershell recycle script

Cognos Express TM1 Powershell recycle script

by Darek Danielewski

by Darek Danielewski

IBM Cognos TM1

A number of things to consider when implementing your IBM Cognos TM1 environment.  TM1 is an in-memory OLAP engine which will leverage large amounts of contiguous memory on your system.  In order for your IBM Cognos TM1 Models/Applications to be at their best we recommend leveraging PowerShell to recycle and notify you of any issues with your TM1 Models.

To ensure that your are getting the most of your TM1 applications ensure you schedule your recycle script at least weekly.

Please feel free to implement or ask questions about the below script.

Script Information:

Copy and past the blow into a text file and rename the file to tm1recycle.ps1

# This script will delete files within the TM1 Logs folder and files within sub-folders older than 3 Days
# This script will also Stop and Start the TM1 applications to release the resources that have been consumed in a week.
# This script will also notify the group of users if the services do not start.

$Path = “C:\Program Files\IBM\Cognos Express\logs\express”
$Daysback = “-3”
# Enter a number to indicate how many days old the identified file needs to be (must have a “-” in front of it).
$CurrentDate = Get-Date
$DatetoDelete = $CurrentDate.AddDays($Daysback)
get-childitem $Path -Recurse | Where-Object {$_.LastWriteTime -lt $DatetoDelete } | Remove-Item

# Stop the TM1 Applications
stop-service “CXMD”

# Start the TM1 Applications
start-service “CXMD”

# Notification CXMD Service
# Get the server name
# the Logs folder needs to be created under the C:\Program Files\IBM directory
$hostName = hostname | out-file C:\Progra~1\IBM\Logs\serviceStart.txt -append

function FuncCheckService{
$arrService = Get-Service -Name $ServiceName
$Date = Get-Date -Format “MM/dd/yyyy HH:mm:ss”
$Start = “Started ”
$Started = ” service is already started.”
if ($arrService.Status -ne “Running”){
Start-Service $ServiceName
($Date + ” – ” + $Start + $ServiceName) | Out-file C:\Progra~1\IBM\Logs\serviceStart.txt
if ($arrService.Status -eq “Running”){
($Date + ” – ” + $ServiceName + $Started) | Out-file C:\Progra~1\IBM\Logs\serviceStart.txt

FuncCheckService -ServiceName “CXMD”
$logs = get-content C:\Progra~1\IBM\Logs\serviceStart.txt
# define the email address to send notifiations to
# define the from email address as well as the smtpServer settings
$toAddress = “”

send-mailmessage -from -to $toAddress -subject “The IBM Cognos TM1 Application Services have been recycled” -Body “$logs” -smtpServer

#End of Script


Please feel free to reach out to us with questions.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Optimization WordPress Plugins & Solutions by W3 EDGE