Powershell Get-WmiObject Access is denied

给你一囗甜甜゛ 提交于 2020-01-13 06:00:14

问题


I have a Powershell script containing the following line:

$package = Get-WmiObject -Class Win32_Product -ComputerName $TargetServer -Filter ("Name='{0}'" -f $ApplicationName)

I followed the steps on this answer in order to enable Powershell Remoting between the servers: remoting security steps

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

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?


回答1:


I needed to pass credentials to the Get-WmiObject cmdlet.

I found the answer here:Powershell Masters




回答2:


After guessing for a WHILE, cached credentials were my problem.

Open windows credentials manager:

rundll32.exe keymgr.dll,KRShowKeyMgr

Delete all cached entries.



来源:https://stackoverflow.com/questions/11968210/powershell-get-wmiobject-access-is-denied

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!