“get-wmiobject win32_process -computername"得到错误“拒绝访问,代码 0x80070005"; [英] "get-wmiobject win32_process -computername" gets error "Access denied , code 0x80070005"
本文介绍了“get-wmiobject win32_process -computername"得到错误“拒绝访问,代码 0x80070005";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 3 个终端服务器上查找进程,这些进程在其 $_.commandline 属性中包含某些词.在我的域管理员帐户下,它工作正常.但是我希望这个脚本对域用户可用,而doamin用户在运行这个脚本时会出错.
i'm trying to find processes on 3 terminal servers which have certain words in its $_.commandline property. Under my domain admin account, it worked OK. But I want this script to be usable for domain users, and doamin users get an error when runing this script.
我应该怎么做,以便域用户可以像域管理员一样运行此脚本?提前致谢!
What should i do, so that domain users can run this script just like domain admins? Thanks in advance!
错误:
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 代码:
Powershell Code:
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!"
推荐答案
好的步骤如下:
- 启动wmimgmt.msc"
- 右键单击WMI 控件(本地)",然后选择属性
- 转到安全"选项卡,然后依次选择安全"、高级"和添加"
- 选择您要授予 WMI 访问权限的用户名或组,然后单击确定
- 授予所需的权限,我建议首先授予所有权限以确保授予访问权限,然后根据需要删除权限.
- 确保应用到"选项设置为此命名空间和子命名空间"
- 保存并退出所有提示
- 将用户或组添加到本地分布式 COM 用户"组.注意:此处无法添加Authenticated Users"和Everyone"组,因此您可以选择使用域用户"组.
这篇关于“get-wmiobject win32_process -computername"得到错误“拒绝访问,代码 0x80070005";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文