# wmic vs gwmi

**URL:** <https://forums.powershell.org/t/wmic-vs-gwmi/4134>\
**Category:** PowerShell Help\
**Created:** [April 30, 2015, 10:08pm UTC](https://forums.powershell.org/t/wmic-vs-gwmi/4134 "2015-04-30T22:08:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ganeshbabu-jeyabalan](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@ganeshbabu-jeyabalan](https://forums.powershell.org/u/ganeshbabu-jeyabalan)\
**Post date:** [April 30, 2015, 10:08pm UTC](https://forums.powershell.org/t/wmic-vs-gwmi/4134/1 "2015-04-30T22:08:41Z")

</div>

Hello All,

I am in need of getting the RDP certhash of a remote machine. I found a way to get the same using wmic and it works absolutely fine. I am trying the same with powershell on the same console but I am receiving Access Denied error. Am I doing something wrong?

```
PS C:\> wmic /node:Testserver /namespace:\\root\CIMV2\TerminalServices PATH Win32_TSGeneralSetting get SSLCertificateSHA1Hash
SSLCertificateSHA1Hash
1F463C2D9742AA3CE038A0C216FF179418C790EA

PS C:\>
PS C:\> gwmi Win32_TSGeneralSetting -Namespace "root\cimv2\terminalservices" -ComputerName Testserver | select -ExpandProperty SSLCertificateSHA1Hash
gwmi : Access denied
At line:1 char:1
+ gwmi Win32_TSGeneralSetting -Namespace "root\cimv2\terminalservices" -ComputerN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
```

---

<div class="post-metadata">

**Author:** ![richard-siddaway](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@richard-siddaway](https://forums.powershell.org/u/richard-siddaway)\
**Post date:** [April 30, 2015, 10:21pm UTC](https://forums.powershell.org/t/wmic-vs-gwmi/4134/2 "2015-04-30T22:21:52Z")

</div>

I just tried this

Get-WmiObject -Namespace root\cimv2\TerminalServices -Class Win32\_TSgeneralSetting -ComputerName W12R2SUS

against a remote Windows 2012 R2 machine and it worked.

Access denied is usually a permissions problem. Can you access a standard class on the remote machine using Get-WmiObject?

You may need to create a credential object and use that with Get-WmiObject.

Alternatively try Get-CimInstance. It runs over WSMAN and doesn’t trip over so many issues as Get-WmiObject  
Get-CimInstance -Namespace root\cimv2\TerminalServices -ClassName Win32\_TSgeneralSetting -ComputerName W12R2SUS

---

<div class="post-metadata">

**Author:** ![ganeshbabu-jeyabalan](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@ganeshbabu-jeyabalan](https://forums.powershell.org/u/ganeshbabu-jeyabalan)\
**Post date:** [May 1, 2015, 2:11am UTC](https://forums.powershell.org/t/wmic-vs-gwmi/4134/3 "2015-05-01T02:11:41Z")

</div>

Thanks Richard. I have admin rights on the remote machine and I am able to access the remote server’s standard class wmi using gwmi such as win32\_bios. I have also tried supplying the credential (domain as well the local built in admin) as suggested - but still no luck.

My environment is not setup with PS remoting yet but I still enabled it only on this remote machine to check this issue with get-ciminstance. But I was getting “A DMTF resource URI was used to access a non-DMTF class. Try again using a non-DMTF resource URI.”. Then I saw your article and got to know the problem is due to wsman3 and 2 connection conflicts. I was running these commands from windows 2012 (PS3) to the remote Windows 2008R2 machine. Finally I managed to get it working with mix and match WSMAN and DCOM based CIM sessions and I could get the RDP certhash.

I tried using the same gwmi command from windows 2012(PS V3) to remote windows 2008/2012/R2 machines and still have the same problem. But when i use it from windows 2012 R2 to remote machines with any os 2008/12/R2 everything works fine. So looks like it is fixed in PS V4. .

---

<div class="post-metadata">

**Author:** ![alberto-vargas](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@alberto-vargas](https://forums.powershell.org/u/alberto-vargas)\
**Post date:** [May 1, 2015, 11:48pm UTC](https://forums.powershell.org/t/wmic-vs-gwmi/4134/4 "2015-05-01T23:48:26Z")

</div>

When ever you see Access denied (raised by: Get-WmiObject) simply add -Authentication PacketPrivacy to the gwmi cmdlet.  
gwmi Win32\_TSGeneralSetting -Namespace “root\cimv2\terminalservices” -Computername blah -Authentication PacketPrivacy

---

<div class="post-metadata">

**Author:** ![ganeshbabu-jeyabalan](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@ganeshbabu-jeyabalan](https://forums.powershell.org/u/ganeshbabu-jeyabalan)\
**Post date:** [May 3, 2015, 5:26am UTC](https://forums.powershell.org/t/wmic-vs-gwmi/4134/5 "2015-05-03T05:26:40Z")

</div>

@albvar01 - Awesome. Thank you. It works with -Authentication PacketPrivacy on PS v3.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:45pm UTC](https://forums.powershell.org/t/wmic-vs-gwmi/4134/6 "2024-05-16T20:45:20Z")

</div>


