powershell - 使用 powershell 将 com+ 组件添加到现有的空 com+ 应用程序包?

标签 powershell powershell-2.0 com+

我正在尝试尽可能自动化我的服务器安装。

其中一部分包括创建 COM+ 包(我目前使用 PS 进行此操作)。然后我需要将组件添加到这些空应用程序包中。 DLL 已预先注册到 RegASM。 目前,我正在通过 DCOM 配置 GUI 手动添加组件(添加已注册的组件\32 位组件)。然后,我在添加每个组件后通过属性设置它们的事务支持级别。在具有 50 多个组件的应用程序上,这可能会非常耗时,因此需要自动化。

我找到了一个删除特定组件的脚本...

$comCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog
$appColl = $comCatalog.GetCollection("Applications")
$appColl.Populate()

$app = $appColl | where {$_.Name -eq "COMAPPNAME"}
$compColl = $appColl.GetCollection("Components", $app.Key)
$compColl.Populate()

$index = 0
foreach($component in $compColl) {
if ($component.Name -eq "SOMECOMPONENT.NAME") {
    $compColl.Remove($index)
    $compColl.SaveChanges()
}
$index++
}

...修改上面的内容,这是我到目前为止所拥有的,但是它与存在的位数和交易选项有关。没有这些,它运行不会出错。但是,似乎什么也没有发生。我的 COM+ 应用程序中没有出现任何组件。

$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection(“Applications”)
$apps.Populate();
$app = $apps | where {$_.Name -eq "App1"}
$compColl = $apps.GetCollection("Components", $app.Key)
$compColl.Populate()
$component = $compColl.Add
$component.Value(“Bitness”) = 0x1
$component.Value(“Transaction”) = 2
$component.Name -eq "App1.Component1" 
$compColl.SaveChanges()

$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection(“Applications”)
$apps.Populate();
$app = $apps | where {$_.Name -eq "App1"}
$compColl = $apps.GetCollection("Components", $app.Key)
$compColl.Populate()
$component = $compColl.Add
$component.Value(“Bitness”) = 0x1
$component.Value(“Transaction”) = 3
$component.Name -eq "App1.Component2" 
$compColl.SaveChanges()

任何帮助将不胜感激! 谢谢!

最佳答案

我找到了合适的解决方案:

$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog;
$comAdmin.InstallComponent("ApplicationName", [DLL containing components]);

这正是我所需要的。

关于powershell - 使用 powershell 将 com+ 组件添加到现有的空 com+ 应用程序包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27442421/

相关文章:

powershell-2.0 - 转义引号和双引号

powershell - Powershell远程查询Server 2003的事件日志

powershell - 如何将 foreach 循环输出转储到 PowerShell 中的文件中?

c# - 检查 COM+ 应用程序是否已经在运行?

c++ - regsvr32 导致 CDatabase destrucor 在使用 SQL Native Client (v2005) 时挂起

powershell - 已弃用的 wmic 的 cmd/batch 替代品是什么?

Powershell 5 : Cannot convert value To System. 字符串

windows - COM+ 库应用程序的用途是什么?

powershell - 另一个具有相同属性identifierUris值的对象已存在

powershell - 遍历嵌套的广告组,直到找到所有成员