Damien
Damien

Reputation: 684

Why is Powershell's Get-ItemProperty not returning the same values as seen in regedit.exe?

I am setting up a machine for testing, and part of that is tinkering with some registry values. This is an Azure VM, and I am configuring it via Powershell.

I am noticing many differences between the Registry values returned from Get-ItemProperty (in Powershell) and the Registry values I see in regedit.exe. Below is an example of one such difference:

Get-ItemProperty:

enter image description here

regedit.exe:

enter image description here

Note DefaultUserName is set when viewed in regedit.exe

I am setting these properties using New-ItemProperty (with a -Force parameter).

Any help is appreciated.

Upvotes: 2

Views: 1868

Answers (1)

Mötz
Mötz

Reputation: 1732

I don't have an answer right now, but have some ideas you can try out.

List all keys using the commandline

reg.exe query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"

List all keys using PowerShell

(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\").PSObject.Properties | where-object name -notlike PS* | Format-Table Name, value

That should make it easier for you to compare the results that PowerShell is generating and what the commandline is generating.

Want to count the number of entries in PowerShell

((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\").PSObject.Properties | where-object name -notlike PS*).count

I have tested against 2 different laptops and have seen no differences.

I have tested against 4 different Azure VMs and have seen no differences.

If you are creating new registry keys, I would restart the PowerShell console before retrieving the registry keys again. Just to make sure.

Otherwise you should consider exporting the registry key from regedit.exe and look at the path generated in the file.

Upvotes: 1

Related Questions