In a number of blog posts I have been writing about how to create a log for your runbooks. The solution I like the most is to write to a SQL database. Even if you do that there is always a small risk that some colleagues don’t write the log in the same way. For example someone use 1-2-3 instead of low-medium-high when writing severity. One way to handle that is data validation in your log runbook. Another way is to create a new activity where colleagues can pick from menus.
First thing you need to build a “write to log” activity is a Powershell script that do the “write to database” part.
param($Argument1,$Argument2,$Argument3)
$DESCRIPTION = $Argument3
$DESCRIPTION = $description.replace("'","''")
$DATE = get-date -format s
$RUNBOOK = $Argument1
$SEVERITY = $Argument2
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Data Source=SCO12SP1-01;Initial Catalog=OrchestratorTool;Integrated Security=SSPI;"
$conn.open()
$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmd.connection = $conn
$cmd.CommandText = "INSERT INTO Log (DATE,RUNBOOK,SEVERITY,DESCRIPTION)
VALUES ('$DATE','$RUNBOOK','$SEVERITY','$DESCRIPTION')"
$cmd.executenonquery()
$conn.close()
As you can see the SQL server name (SCO12SP1-01) and the SQL database name (OrchestratorTool) is hardcoded into the script. This is because that will not change, when using this activity we will always write to the same log database. Once the script is ready we can use the Orchestrator Integration Toolkit to build an activity and an integration pack. When configure the activity, configure it to run the Powershell script and pass the arguments.
When building the integration pack make sure to attach the PowerShell script. The Powershell script will be deployed together with the integration pack to all your runbook servers. Note that the Severity parameter is configured as Selection. It is configured as a drop down menu where users can pick severity from a list.
When using the activity you can pick severity from a menu. Runbook Name is published by all activities by default.
You can download the integration pack and example files here, NOT SUPPORTED. Note that this is provided “AS-IS†with no warranties at all. This is not a production ready solution, just an idea and an example.
Hi HÃ¥kan, take a look at this example http://contoso.se/blog/?p=2449
edit that…I just found your SMA post here: http://contoso.se/blog/?p=3870
Can you please explain how you would do the same thing in SMA as an integration module?
Could you please show us how you created the activity in OIT or link to a god example how to make the activity and call the powershellscript. Thx /HÃ¥kan