getwmi php 报错,powershell – “get-wmiobject win32_process -computername”获取错误“访问被拒绝,代码0x80070005”...

我正在尝试在3个终端服务器上找到其$_.命令行属性中包含某些单词的进程.在我的域管理员帐户下,它工作正常.但我希望此脚本可用于域用户,并且运行此脚本时doamin用户会收到错误.

我应该怎么做,以便域用户可以像域管理员一样运行此脚本?提前致谢!

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!"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值