How to modify COM+ applications from powershell
Asked Answered
A

1

5

I am automating the creation of a web server. An application is created for me, but I need to manually change the Identity of a COM+ Application to run as a specific user.

enter image description here

Being a linux admin with little experience with powershell, I'm in over my head. It looks like there is an API to modify COM+ applications.

https://msdn.microsoft.com/en-us/library/ms679173(v=vs.85).aspx

From this stackoverflow question, I've gotten this far in modifying the application

$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection(“Applications”)
$apps.Populate();

I am able to see my application in the list by typing in this command

$apps

enter image description here

Is it possible to modify the foobar application Identity from powershell?

Abridgment answered 25/2, 2015 at 20:33 Comment(1)
I don't know for sure whether it's possible or how, but if the COM object can't do it you might want to see if there's a way to do it with WMI.Aleutian
A
8

Thanks to this stackoverflow question, I got it working.

$targetApp = "examplecompany"
$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection("Applications")
$apps.Populate();
$app = $apps | Where-Object {$_.Name -eq $targetApp}
$comAdmin.ShutdownApplication($targetApp)

$app.Value("Identity") = 'example.com\exampleuser'
$app.Value("Password") = 'correct-horse-battery-staple'
$apps.SaveChanges()
$comAdmin.StartApplication($targetApp)
Abridgment answered 25/2, 2015 at 21:47 Comment(1)
The Update to $comAdmin,ShutdownApplication line would fail if $app somehow contains multiple apps, I suggested a change in the edit of your answer.Santamaria

© 2022 - 2024 — McMap. All rights reserved.