Answers:
以下适用于Windows 2003 R2 SP 2,Windows Server 2012 R2
wmimgmt.msc
)。在“安全性”选项卡中,突出显示Root/CIMV2
,单击“安全性”。添加 性能监视器用户并启用选项:Enable Account
和Remote Enable
dcomcnfg
。在“组件服务”>“计算机”>“我的电脑”上,在“属性”对话框的COM安全性选项卡中,为Access Permissions
和分别单击“编辑限制” Launch and Activation Permissions
。添加性能监视器用户,并允许远程访问,远程启动和远程激活。Remote Launch
并Remote Activation
为Performance Monitor Users组赋予特权。笔记:
Root
级别2中设置设置,然后通过Advanced
窗口中的子窗口递归对子命名空间的权限。Security
默认情况下,只有本地Administrators组具有对WMI的远程权限。您将必须自定义WMI“远程启用”权限。
根据选择的答案,我修改了Microsoft的脚本来设置WMI安全性。我的测试用户是一个非管理域用户,出于与该问题无关的原因,该用户是本地系统上“远程管理用户”的成员。在向用户授予对目标名称空间的EnableAccount,RemoteEnable和ExecuteMethods权限后,我便能够访问WMI。
所以,我并没有我的用户添加到性能监视器用户或分布式COM用户本地组。
有关脚本的一些注意事项:
$OBJECT_INHERIT_ACE_FLAG
该脚本如下。我将其命名为Set-WMINamespaceSsecurity.ps1
Param ([Parameter(Mandatory=$true,Position=0)] [string]$Namespace,
[Parameter(Mandatory=$true,Position=1)] [ValidateSet("Add","Remove")] [string]$Operation,
[Parameter(Mandatory=$true,Position=2)] [string] $Account,
[Parameter(Mandatory=$false,Position=3)] [ValidateSet("EnableAccount","ExecuteMethods","FullWrite","PartialWrite","ProviderWrite","RemoteEnable","ReadSecurity","WriteSecurity")] [string[]] $Permissions=$null,
[Parameter(Mandatory=$false)] [switch]$AllowInherit,
[Parameter(Mandatory=$false)] [switch]$Deny,
[Parameter(Mandatory=$false)] [string]$ComputerName=".",
[Parameter(Mandatory=$false)] [System.Management.Automation.PSCredential]$Credential=$null)
$OBJECT_INHERIT_ACE_FLAG = 0x1
$CONTAINER_INHERIT_ACE_FLAG = 0x2
$ACCESS_ALLOWED_ACE_TYPE = 0x0
$ACCESS_DENIED_ACE_TYPE = 0x1
$WBEM_ENABLE = 0x01
$WBEM_METHOD_EXECUTE = 0x02
$WBEM_FULL_WRITE_REP = 0x04
$WBEM_PARTIAL_WRITE_REP = 0x08
$WBEM_WRITE_PROVIDER = 0x10
$WBEM_REMOTE_ACCESS = 0x20
$WBEM_RIGHT_SUBSCRIBE = 0x40
$WBEM_RIGHT_PUBLISH = 0x80
$READ_CONTROL = 0x20000
$WRITE_DAC = 0x40000
$WBEM_S_SUBJECT_TO_SDS = 0x43003
$ErrorActionPreference = "Stop"
$InvokeParams=@{Namespace=$Namespace;Path="__systemsecurity=@";ComputerName=$ComputerName}
if ($PSBoundParameters.ContainsKey("Credential")) { $InvokeParams+= @{Credential=$Credential}}
$output = Invoke-WmiMethod @InvokeParams -Name "GetSecurityDescriptor"
if ($output.ReturnValue -ne 0) { throw "GetSecurityDescriptor failed: $($output.ReturnValue)" }
$ACL = $output.Descriptor
if ($Account.Contains('\')) {
$Domain=$Account.Split('\')[0]
if (($Domain -eq ".") -or ($Domain -eq "BUILTIN")) { $Domain = $ComputerName }
$AccountName=$Account.Split('\')[1]
}
elseif ($Account.Contains('@')) {
$Somain=$Account.Split('@')[1].Split('.')[0]
$AccountName=$Account.Split('@')[0]
}
else {
$Domain = $ComputerName
$AccountName = $Account
}
$GetParams = @{Class="Win32_Account" ;Filter="Domain='$Domain' and Name='$AccountName'"}
$Win32Account = Get-WmiObject @GetParams
if ($Win32Account -eq $null) { throw "Account was not found: $Account" }
# Add Operation
if ($Operation -eq "Add") {
if ($Permissions -eq $null) { throw "Permissions must be specified for an add operation" }
# Construct AccessMask
$AccessMask=0
$WBEM_RIGHTS_FLAGS=$WBEM_ENABLE,$WBEM_METHOD_EXECUTE,$WBEM_FULL_WRITE_REP,$WBEM_PARTIAL_WRITE_REP,$WBEM_WRITE_PROVIDER,$WBEM_REMOTE_ACCESS,$READ_CONTROL,$WRITE_DAC
$WBEM_RIGHTS_STRINGS="EnableAccount","ExecuteMethods","FullWrite","PartialWrite","ProviderWrite","RemoteEnable","ReadSecurity","WriteSecurity"
$PermissionTable=@{}
for ($i=0; $i -lt $WBEM_RIGHTS_FLAGS.Count; $i++) { $PermissionTable.Add($WBEM_RIGHTS_STRINGS[$i].ToLower(), $WBEM_RIGHTS_FLAGS[$i]) }
foreach ($Permission in $Permissions) { $AccessMask+=$PermissionTable[$Permission.ToLower()] }
$ACE=(New-Object System.Management.ManagementClass("Win32_Ace")).CreateInstance()
$ACE.AccessMask=$AccessMask
# Do not use $OBJECT_INHERIT_ACE_FLAG. There are no leaf objects here.
if ($AllowInherit.IsPresent) { $ACE.AceFlags=$CONTAINER_INHERIT_ACE_FLAG }
else { $ACE.AceFlags=0 }
$Trustee=(New-Object System.Management.ManagementClass("Win32_Trustee")).CreateInstance()
$Trustee.SidString = $Win32Account.SID
$ACE.Trustee=$Trustee
if ($Deny.IsPresent) { $ACE.AceType = $ACCESS_DENIED_ACE_TYPE } else { $ACE.AceType = $ACCESS_ALLOWED_ACE_TYPE }
$ACL.DACL+=$ACE
}
#Remove Operation
else {
if ($Permissions -ne $null) { Write-Warning "Permissions are ignored for a remove operation" }
[System.Management.ManagementBaseObject[]]$newDACL = @()
foreach ($ACE in $ACL.DACL) {
if ($ACE.Trustee.SidString -ne $Win32Account.SID) { $newDACL+=$ACE }
}
$ACL.DACL = $newDACL
}
$SetParams=@{Name="SetSecurityDescriptor"; ArgumentList=$ACL}+$InvokeParams
$output = Invoke-WmiMethod @SetParams
if ($output.ReturnValue -ne 0) { throw "SetSecurityDescriptor failed: $($output.ReturnValue)" }
我们针对PRTG进行了此操作:我们创建了一个新的域用户:创建了一个GPO Dit将其用户置于“性能日志用户”组中,并使用powershell脚本将该用户添加到WMI Control中。谢谢: