[英]How to run `Get-CimInstance` as non-admin user (windows server 2019, powershell 5.1)
I am trying to run a powershell command on a server very similar to this one.我正在尝试在与此非常相似的服务器上运行 powershell 命令。
https://stackoverflow.com/a/55942155/4577279 https://stackoverflow.com/a/55942155/4577279
The problem is that the script is being run by a non-admin user, and it fails to run the Get-CimInstance
command.问题是脚本由非管理员用户运行,并且无法运行Get-CimInstance
命令。
it fails with它失败了
Get-CimInstance : Access denied
At C:\bin\SCRIPT.ps1:6 char:5
+ Get-CimInstance Win32_Process | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (root\cimv2:Win32_Process:String) [Get-CimInstance], CimException
+ FullyQualifiedErrorId : HRESULT 0x80041003,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand
The command is run by an instance of windows server 2019 on a remote box.该命令由远程框上的 Windows Server 2019 实例运行。 The script in question is on the box as well.有问题的脚本也在盒子上。
How can I allow for the non-admin user to run this command without having to run it as administrator?如何允许非管理员用户运行此命令而不必以管理员身份运行它? I am in full control of the server and can modify the permissions, but I'm not sure how to approach that.我完全控制服务器并且可以修改权限,但我不确定如何处理。 The script should be run by a non-admin if at all possible.如果可能,脚本应该由非管理员运行。
alternatively if there is a different way to get the entire children process tree for a given PID, that could work, too.或者,如果有一种不同的方法来获取给定 PID 的整个子进程树,那也可以。
Thank you谢谢
By default, Administrators
(local) and Authenticated Users
(domain) have at least read rights to the namespace.默认情况下, Administrators
(本地)和经过Authenticated Users
(域)至少具有对命名空间的读取权限。 You need to ensure you can login/authenticate to the server.您需要确保您可以登录/验证服务器。 It's worth mentioning that the Authenticated Users
group does not have Remote Enable
permission by default.值得一提的是, Authenticated Users
组默认没有Remote Enable
权限。 see this answer for more information - What are the permissions required for CIMSessions有关更多信息,请参阅此答案 - CIMSessions 需要哪些权限
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.