Monday, November 12, 2007

PowerShell Shutdown COM+

To shutdown a COM+ object, so you can redeploy the binaries it uses, I had a VBS script to do it. I wondered how I could do it in PowerShell, but lacked time to do so. I just stumbled upon some code to do it, though.

The old script was:

Dim oCatalog ' As COMAdmin.COMAdminCatalog
Dim sName 'As String
Dim sMachine 'As String
Set oCatalog = CreateObject("COMAdmin.COMAdminCatalog")
sName = "Tridion Content Manager"
sMachine = "tridionserver"

oCatalog.Connect sMachine
oCatalog.ShutdownApplication sName



And this became:


$TridionAppName = "Tridion Content Manager"
$TridionMachine = "tridionserver"

$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$comAdmin.Connect($TridionMachine)
$comAdmin.ShutdownApplication($TridionAppName)


(Just leave the line with the call to connect out to run this on your local machine).