Powershell Get-WmiObject 访问被拒绝 [英] Powershell Get-WmiObject Access is denied
问题描述
我有一个包含以下行的 Powershell 脚本:
I have a Powershell script containing the following line:
$package = Get-WmiObject -Class Win32_Product -ComputerName $TargetServer -Filter ("Name='{0}'" -f $ApplicationName)
我按照此答案中的步骤启用服务器之间的 Powershell 远程处理:远程安全步骤
I followed the steps on this answer in order to enable Powershell Remoting between the servers: remoting security steps
当我从 Powershell ISE(在提升的管理窗口中)运行脚本时,我收到以下错误:
When I run the script from the Powershell ISE (in an elevated admin window) then I get the following error:
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At line:1 char:14
+ Get-WmiObject <<<< win32_bios -computername d-vasbiz01
+ CategoryInfo : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
我需要能够在 ISE 中运行脚本,以便我可以解决其他问题.
I need to be able to run the script in the ISE so that I can troubleshoot other problems.
谁能建议我需要做些什么来修复这个安全错误?
Can anyone please suggest what I need to do to fix this security error?
推荐答案
我需要将凭据传递给 Get-WmiObject cmdlet.
I needed to pass credentials to the Get-WmiObject cmdlet.
我在这里找到了答案:Powershell Masters一个>
这篇关于Powershell Get-WmiObject 访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!