powershell - 为什么远程计算机上的Powershell查询会引发访问被拒绝错误?

标签 powershell permissions wmi

当我在连接到远程计算机的计算机上执行简单的PowerShell查询时,我从PowerShell ISE中收到此类错误:

Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At line:8 char:43
+                     $WmiOS = Get-WmiObject <<<<  -Class Win32_OperatingSystem -ComputerName    $targetComputer -credential $credential    
+ CategoryInfo          : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

You cannot call a method on a null-valued expression.
At line:9 char:45
+                     $WmiOS.ConvertToDateTime <<<< ($WmiOS.LastBootUpTime)            
+ CategoryInfo          : InvalidOperation: (ConvertToDateTime:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

但是,相同的查询将在我的其他团队成员的计算机(或任何其他计算机)上正常工作,而不会出现任何问题。

我们尝试执行的脚本示例:
                $WmiOS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $targetComputer -credential $credential    
                $WmiOS.ConvertToDateTime($WmiOS.LastBootUpTime)  

有任何想法吗?

最佳答案

尝试将以下标志添加到Get-WmiObject命令:

-Authentication PacketPrivacy -Impersonation Impersonate

关于powershell - 为什么远程计算机上的Powershell查询会引发访问被拒绝错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7043437/

相关文章:

powershell - Powershell与管道中的可枚举

powershell - 使用 powershell 从多台计算机中提取注册表值

powershell - Powershell获取包含最后日期的文件

Android:java.lang.SecurityException:权限拒绝:启动 Intent

powershell - 在PowerShell中是否存在用于检查别名存在的命令?

eclipse - 运行 Eclipse 需要哪些权限?

android - 检测到屏幕覆盖 - 如何在屏幕覆盖应用中处理此问题

c++ - 如何以日期时间格式获取 Win32_OperatingSystem.LastBootUpTime

c# - guest 帐户限制

windows - 在 Windows XP/7 中获取 EDID 的 Win32 代码