通过PowerShell更改DCOM对象权限后要重新启动什么?

问题描述 投票:0回答:1

我正在使用PowerShell成功设置DCOM对象的权限。

尽管,此后,当我的软件使用DCOM对象时,只有在重新启动计算机后才能识别权限更改。

如何防止重新启动?更改权限后,我是否可以重新启动一个组件/服务?

我正在使用此代码来更改权限:

$apiDCOMObj = Get-WmiObject -Query ('SELECT * FROM Win32_DCOMApplicationSetting WHERE Caption = "MyAPI"') -EnableAllPrivileges
$descrLaunch = $apiDCOMObj.GetLaunchSecurityDescriptor().descriptor
$descrAccess = $apiDCOMObj.GetAccessSecurityDescriptor().descriptor
$trusteeObj = ([wmiclass]'Win32_Trustee').psbase.CreateInstance()
$trusteeObj.Domain = "NT AUTHORITY"
$trusteeObj.Name = "NETWORK SERVICE"
$aceLaunch = ([wmiclass]'Win32_ACE').psbase.CreateInstance()
$aceLaunch.AccessMask = 11                                            # Mask for Local Launch and Local Activation
$aceLaunch.trustee = $trusteeObj
$aceAccess = ([wmiclass]'Win32_ACE').psbase.CreateInstance()
$aceAccess.AccessMask = 3                                             # Mask for Local Access
$aceAccess.trustee = $trusteeObj
$descrLaunch.DACL += [System.Management.ManagementBaseObject]$aceLaunch
$descrAccess.DACL += [System.Management.ManagementBaseObject]$aceAccess
$apiDCOMObj.SetLaunchSecurityDescriptor($descrLaunch)
$apiDCOMObj.SetAccessSecurityDescriptor($descrAccess)
powershell dcom
1个回答
0
投票

您可以呼叫Restart-Service

Restart-Service -Name <your_service_name>

这将使用新的权限重新启动服务。

© www.soinside.com 2019 - 2024. All rights reserved.