Access to Get-WmiObject for Powershell denied

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 described in this answer to allow switching between Powershell Remoting servers: remove security steps

When I run the script from ISE Powershell (in a window with an elevated administrator), 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 a script in ISE so that I can fix other problems.

Can anyone suggest what I need to do to fix this security error?

+2
source share
1 answer

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

I found the answer here: Powershell Wizards

+2

Source: https://habr.com/ru/post/1531738/


All Articles