This script is for running a re-synchronisation of the Orchestrator runbooks in System Center Service Manager (SCSM).

The SCORCH connector in SCSM syncs all the runbooks through from SCORCH. Sometimes even after running a sync, a new runbook will not appear. Using the Truncate AuthorizationCache in SQL can resolve this but not always.

The script does the following:

 

Requirements:

 

 

PowerShell
Edit|Remove
Param( 
    [string]$SQLServer, 
    [string]$DBName = 'Orchestrator', 
    [string]$ManagementServer, 
    [string]$SCSMConnector 
) 
 
 
 
Write-Host 'Truncating Orchestrator Authorisation Cache..' -ForegroundColor Yellow 
 
 
Try 
{ 
    $SqlQuery = 'TRUNCATE TABLE [Microsoft.SystemCenter.Orchestrator.Internal].AuthorizationCache' 
    Write-Verbose -Message "Query: $SqlQuery" 
    $SqlConnection = New-Object -TypeName System.Data.SqlClient.SqlConnection 
    $SqlConnection.ConnectionString = "Server = $SQLServer; Database = $DBName; Integrated Security = True" 
    $SqlConnection.Open() 
    $SqlCmd = New-Object -TypeName System.Data.SqlClient.SqlCommand 
    $SqlCmd.CommandTimeout = 600000 
    $SqlCmd.Connection = $SqlConnection 
    $SqlCmd.CommandText = $SqlQuery 
    $result = $SqlCmd.ExecuteReader() 
    $result 
    Write-Host 'Successfully Truncated the Orchestrator AuthorizationCache' -ForegroundColor Green 
} 
Catch 
{ 
    $_.Exception.Message 
    break 
} 
 
 
 
Write-Host 'Restarting IIS Services...' -ForegroundColor Yellow 
    iisreset.exe 
 
 
 
 
Write-Host "Running a Sync Now for SCORCH Connector $SCSMConnector please wait..." -ForegroundColor Yellow 
 
Try 
{ 
    $Script = { 
    Param($Displayname) 
    Import-Module -Name SMLets 
    Get-SCSMConnector -DisplayName $Displayname | Start-SCSMConnector 
    } 
 
    $SyncNow = Invoke-Command -ComputerName $ManagementServer -ScriptBlock $Script -ArgumentList $SCSMConnector 
    Write-Host "Successfully Synchronised $SCSMConnector"  -ForegroundColor Green 
    Return $SyncNow 
} 
Catch 
{ 
    $_.Exception.Message 
    break 
}