简体   繁体   English

PowerShell启用设置COM +安全框

[英]PowerShell to enable set COM+ security box

I am writing a script to enable the checkbox Enforce component level access checks and to check the box before the role. 我正在编写一个脚本,以启用“ 强制执行组件级访问权限 ”复选框并选中该角色之前的复选框。

This is the code I have so far (change to the name of the COM+ app): 这是我到目前为止的代码(更改为COM +应用程序的名称):

$comAdmin = New-Object -ComObject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection('Applications')
$apps.Populate()
$targetApp = '<appname>'
$app = $apps | Where-Object -FilterScript {
    $_.Name -eq $targetApp
}
$components = $apps.GetCollection('Components',$app.key)
$components.Populate()

foreach ($component in $components)
{
    $componentName = $component.Name
    $componentID = $component.Value('CLSID')
}



$accesschecks = $component.Value('ComponentAccessChecksEnabled')
$component.Value('ComponentAccessChecksEnabled') = $true
$components.SaveChanges()




$comAdmin = New-Object -ComObject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection('Applications')
$apps.Populate()

$app = $apps|Where-Object -FilterScript {
    $_.Name -eq $targetApp
}
$components = $apps.GetCollection('Components', $app.Key)
$components.Populate()
$components.GetCollection('RolesForComponent', $component.Key)

foreach ($component in $components)
{
    $component.Value('ComponentAccessChecksEnabled') = $true
    $component.value('RolesForComponentEnabled') = #t
    '{0,-30}{2,-10}{1}{1}' -f $component.Name, $component.Value('CLSID'), $component.Value('ComponentAccessChecksEnabled'), $component.Key

}
$components.SaveChanges()

The first part of the scripts works, it enables the checkbox. 脚本的第一部分起作用,它启用了复选框。 But the second part does not checks the checkbox before the role. 但是第二部分不选择角色前面的复选框。 It now looks like this: 现在看起来像这样:

在此处输入图片说明

I need bit of help to get the script to work to check the box. 我需要一点帮助才能使脚本正常工作以选中该框。 Any ideas? 有任何想法吗?

Check if it is possible to enable the checkbox via the registry. 检查是否可以通过注册表启用该复选框。 If you've already the ClassId of the COM object you can search the registry after it. 如果您已经拥有COM对象的ClassId,则可以在其后搜索注册表。 If it is stored in the registry you can change the key via Set-ItemProperty . 如果它存储在注册表中,则可以通过Set-ItemProperty更改密钥。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM