我试图在3个终端服务器上查找$ _。commandline属性中包含某些单词的进程。在我的域管理员帐户下,它工作正常。但是我希望这个脚本对于域用户可用,并且doamin用户在运行这个脚本时会出错。“get-wmiobject win32_process -computername”得到错误“拒绝访问,代码0x80070005”
我该怎么做,以便域用户可以像域管理员一样运行该脚本?提前致谢!
错误:
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESS DENIED))
At N:\FindWhoIsUsing\FindWhoIsUsing.ps1:7 char:18
get-wmiobject <<<< win32_process -computername $server -EnableAllPrivileges|
CategoryInfo : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
PowerShell代码:
Write-host "Who is using this profile?"
$profile = Read-host "specify profile name"
$servers = @("server-01","server-02","server-03")
Foreach($server in $servers)
{
Write-host $server
get-wmiobject win32_process -computername $server -EnableAllPrivileges|
where{$_.name -like "*Processname*" -and
$_.CommandLine -like "*$profile*"}|
select @{n="Server";e={$server}},@{n="User";e={$_.getowner().user}},@{n="ProcessID";e= {$_.ProcessID}},{$_.CommandLine}|fl
}
Write-host "DONE Searching!"
域用户显然缺乏域管理员拥有的所有权限,您需要将他们添加到相关组中,以授予他们所需的访问权限。 – 2013-02-19 08:27:40
是的,我同意你的意见。但问题是,如何?:)我当然不想将所有域用户添加到域管理员,对不对?具体来说,必须有一些WMI控制的地方,但我不知道如何配置它。其实我在目标服务器上的wmimgmt.msc中混淆了一下,但没有运气,也许这是正确的地方,但我没有做对。 – bookends 2013-02-19 08:33:33