如何将特定属性的特定组件添加到PowerShell中的特定COM +应用程序? [英] How do you ADD a specific component with specific properties to a specific COM+ application in PowerShell?

查看:72
本文介绍了如何将特定属性的特定组件添加到PowerShell中的特定COM +应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动化我的服务器安装。



部分内容包括创建COM +包(我目前用PS做)。然后我需要向这些空的应用程序包添加组件。这些DLL已经预先注册了RegASM。

目前我通过DCOM配置GUI手动添加组件(添加已注册的组件\ 32bit组件)。然后,我在每个组件添加后通过属性设置事务支持级别。在具有50多个组件的应用程序上,这可能非常耗时,因此需要自动化。


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

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

$ app = $ appColl |其中{$ _。名称-eqCOMAPPNAME}
$ compColl = $ appColl.GetCollection(Components,$ app.Key)
$ compColl.Populate()

$ index = 0
foreach($ compColl中的$ component){
if($ component.Name -eqSOMECOMPONENT.NAME){
$ compColl.Remove($ index)
$ compColl.SaveChanges()
}
$ index ++
}



...修改上述内容,这是我到目前为止所遇到的Bitness和Transaction选项错误。没有这些,它运行没有错误。但是,似乎没有任何事情发生。我的COM +应用程序中没有组件。

 $ comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog 
$ apps = $ comAdmin.GetCollection(Applications)
$ apps.Populate();
$ app = $ apps |其中{$ _。名称-eqApp1}
$ compColl = $ apps.GetCollection(Components,$ app.Key)
$ compColl.Populate()
$ component = $ compColl.Add
$ component.Value(Bitness)= 0x1
$ component.Value(Transaction)= 2
$ component.Name -eqApp1.Component1
$ compColl.SaveChanges()

$ comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$ apps = $ comAdmin.GetCollection(Applications)
$ apps .Populate();
$ app = $ apps |其中{$ _。名称-eqApp1}
$ compColl = $ apps.GetCollection(Components,$ app.Key)
$ compColl.Populate()
$ component = $ compColl.Add
$ component.Value(Bitness)= 0x1
$ component.Value(Transaction)= 3
$ component.Name -eqApp1.Component2
$ compColl.SaveChanges()



任何帮助都将不胜感激!

谢谢!

解决方案

comCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog


appColl =


comCatalog.GetCollection( 应用程序)

I am wanting to automate my server installations.

Part of this includes Creating COM+ packages (which I do currently with PS). I then need to add components to these empty application packages. The DLLs have been pre-registered with RegASM.
At the moment I am adding the components in manually through DCOM config GUI (add components that are already registered \ 32bit components). I then set the transaction support level on each component through properties after they have been added in. On an application with 50+ components this can get very time consuming, hence the need for automation.

I have found a script to remove specific components...

$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++
}


... Modifying the above, this is what I have so far however it errors with the Bitness and Transaction options present. Without these it runs without error. But, nothing seems to happen. No components appear in my COM+ application.

$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()


Any help would be greatly appreciated!
Thanks!

解决方案

comCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog


appColl =


comCatalog.GetCollection("Applications")


这篇关于如何将特定属性的特定组件添加到PowerShell中的特定COM +应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆