2016-11-14 37 views
0

我正在编写一个脚本来启用复选框强制组件级访问检查并勾选该角色之前的框。启用设置COM +安全框的PowerShell

这是我至今(修改到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

我需要帮助一点,以获得该脚本的工作以检查框。有任何想法吗?

回答

0

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

希望有所帮助。