使用Powershell更改DCOM配置安全设置

Ver*_*min 7 powershell dcom

我被赋予了编写Powershell脚本以从头开始设置服务器以作为Web应用程序的一部分运行我们的服务的任务,并且设置此服务器所需的步骤之一是更改已安装服务的DCOM配置,特别是将帐户添加到"启动和激活"/"访问"权限,并在添加这些帐户后设置这些帐户的权限.

是否有使用Powershell的方法?我无法找到一种具体的方法来实现我的目标,所以任何帮助都会很棒

And*_*ndi 13

看起来你会用WMI做到这一点.

获取一个实例:Win32_DCOMApplicationSetting像这样:

$dcom = Get-WMIObject -Class Win32_DCOMApplicationSetting -Filter 'Description="Something"'
Run Code Online (Sandbox Code Playgroud)

现在您可以访问SetAccessSecurityDescriptorSetLaunchSecurityDescriptor方法了.

来自:http://msdn.microsoft.com/en-us/library/windows/desktop/aa384905(v = vs.85).aspx

DCOM应用程序

DCOM应用程序实例具有多个安全描述符.从Windows Vista开始,使用Win32_DCOMApplicationSetting类的方法来获取或更改各种安全描述符.安全描述符作为Win32_SecurityDescriptor类的实例返回.

要获取或更改配置权限,请调用GetConfigurationSecurityDescriptor或SetConfigurationSecurityDescriptor方法.

要获取或更改访问权限,请调用GetAccessSecurityDescriptor或SetAccessSecurityDescriptor方法.

要获取或更改启动和激活权限,请调用GetLaunchSecurityDescriptor或SetLaunchSecurityDescriptor方法.

Windows Server 2003,Windows XP,Windows 2000,Windows NT 4.0和Windows Me/98/95:Win32_DCOMApplicationSetting安全描述符方法不可用.

还有一个名为DCOMPERM的工具,Windows SDK中提供了源代码:http://www.microsoft.com/en-us/download/details.aspx?id = 8279

如果您搜索DCOMPERM编译,您可以在线找到编译版本.

以下是命令行选项:

Syntax: dcomperm <option> [...] 
Options:

Modify or list the machine access permission list 
-ma <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r"] 
-ma list

Modify or list the machine launch permission list 
-ml <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r,ll,la,rl,ra"] 
-ml list

Modify or list the default access permission list 
-da <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r"] 
-da list

Modify or list the default launch permission list 
-dl <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r,ll,la,rl,ra"] 
-dl list

Modify or list the access permission list for a specific AppID 
-aa <AppID> <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r"] 
-aa <AppID> default 
-aa <AppID> list

Modify or list the launch permission list for a specific AppID 
-al <AppID> <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r,ll,la,rl,ra"] 
-al <AppID> default 
-al <AppID> list

level: 
    ll - local launch (only applies to {ml, dl, al} options) 
    rl - remote launch (only applies to {ml, dl, al} options) 
    la - local activate (only applies to {ml, dl, al} options) 
    ra - remote activate (only applies to {ml, dl, al} options) 
    l - local (local access - means launch and activate when used with {ml, dl, al} options) 
    r - remote (remote access - means launch and activate when used with {ml, dl, al} options)
Run Code Online (Sandbox Code Playgroud)


Eli*_*gne 7

我和OP有同样的问题.Andy发布的答案非常有帮助,让我半途而废.然后我找到了由某人编写的Set-DCOMLaunchPermissions来帮助他们部署SharePoint.

我根据自己的目的调整了功能,并提出了一个设置我需要的权限的解决方案.

$user = "sql2012agent"
$domain = "MYDOMAIN"
$appdesc = "Microsoft SQL Server Integration Services 11.0"
$app = get-wmiobject -query ('SELECT * FROM Win32_DCOMApplicationSetting WHERE Description = "' + $appdesc + '"') -enableallprivileges
#$appid = "{83B33982-693D-4824-B42E-7196AE61BB05}"
#$app = get-wmiobject -query ('SELECT * FROM Win32_DCOMApplicationSetting WHERE AppId = "' + $appid + '"') -enableallprivileges
$sdRes = $app.GetLaunchSecurityDescriptor()
$sd = $sdRes.Descriptor
$trustee = ([wmiclass] 'Win32_Trustee').CreateInstance()
$trustee.Domain = $domain
$trustee.Name = $user
$fullControl = 31
$localLaunchActivate = 11
$ace = ([wmiclass] 'Win32_ACE').CreateInstance()
$ace.AccessMask = $localLaunchActivate
$ace.AceFlags = 0
$ace.AceType = 0
$ace.Trustee = $trustee
[System.Management.ManagementBaseObject[]] $newDACL = $sd.DACL + @($ace)
$sd.DACL = $newDACL
$app.SetLaunchSecurityDescriptor($sd)
Run Code Online (Sandbox Code Playgroud)