powershell – “get-wmiobject win32_process -computername”
发布时间:2020-12-13 20:33:32 所属栏目:Windows 来源:网络整理
导读:我正在尝试在3个终端服务器上找到其$_.命令行属性中包含某些单词的进程.在我的域管理员帐户下,它工作正常.但我希望此脚本可用于域用户,并且运行此脚本时doamin用户会收到错误. 我应该怎么做,以便域用户可以像域管理员一样运行此脚本?提前致谢! 错误: Get-
我正在尝试在3个终端服务器上找到其$_.命令行属性中包含某些单词的进程.在我的域管理员帐户下,它工作正常.但我希望此脚本可用于域用户,并且运行此脚本时doamin用户会收到错误.
我应该怎么做,以便域用户可以像域管理员一样运行此脚本?提前致谢! 错误: Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESS DENIED)) At N:FindWhoIsUsingFindWhoIsUsing.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!"
好的,这里是步骤:
>启动“wmimgmt.msc”>右键单击“WMI Control(Local)”,然后选择“属性”>转到“安全”选项卡并选择“安全”,然后选择“高级”,然后选择“添加”>选择要授予WMI访问权限的用户名或组,然后单击“确定”>授予所需权限,我建议首先授予所有权限以确保访问权限,然后根据需要删除权限.>确保“应用于”选项设置为“此命名空间和子命名空间”>保存并退出所有提示>将用户或组添加到本地“分布式COM用户”组.注意:此处无法添加“Authenticated Users”和“Everyone”组,因此您也可以使用“Domain Users”组. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |