Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

$
0
0

Hi Richard,

I am a newbie to Powershell.  I have been reading and testing code while learning.  Right now, I am stuck on something I am sure is silly.

My code:

#$strUser = Read-Host "Enter user ID"
$strComputer = Read-Host "Printer Report – Enter Computer Name"
$OS = Get-WmiObject -Class win32_OperatingSystem -namespace "root\CIMV2" `
-credential (Get-Credential) -ComputerName $strComputer

When I run this I get the following error:

Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At C:\MyScripts\PrintReport.ps1:3 char:20
+ $OS = Get-WmiObject <<<<  -Class win32_OperatingSystem -namespace "root\CIMV2" `
    + CategoryInfo          : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

Now I do have full admin previledges on remote servers (Windows 2008R2) I am trying to access with this code.  Windows Firewall is completly disabled.  DCOM service is started.  I don't know what else is needed.  I also need to mention that we do have firewalls between servers and TCP port 135 is openned.

Your help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 10624

Trending Articles