PowerShell启用设置COM +安全框

时间:2016-11-14 20:35:37

标签: powershell security com+ dcom

我正在编写一个脚本来启用复选框强制执行组件级别访问检查并选中该角色之前的复选框。

这是我到目前为止的代码(更改为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()

脚本的第一部分工作,它启用复选框。但是第二部分没有检查角色之前的复选框。它现在看起来像这样:

enter image description here

我需要一些帮助来让脚本工作来检查框。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

检查是否可以通过注册表启用该复选框。如果您已经是COM对象的ClassId,则可以在其后搜索注册表。如果它存储在注册表中,您可以通过Set-ItemProperty更改密钥。

希望有所帮助。