Get-Childitem not Returning all results

rated by 0 users
This post has 9 Replies | 3 Followers

Top 100 Contributor
Posts 32
crad14 Posted: 06-29-2011 3:33 PM

When doing a 

get-childitem 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall'

It doesn't return all the objects that are listed there when I browse with regedit. I cannot seem to figure it out either. I also tried a -force and a -include *   with no more luck. 

 

I should also mention that I came to this point when tried this script

$hkey = [Microsoft.Win32.RegistryHive]::LocalMachine;

$registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($hkey, $name)

$reg_uninstall_path = @('Software\Microsoft\Windows\CurrentVersion\Uninstall')

$reg_uninstall_key = ($registry.OpenSubKey($reg_uninstall_path) )

$key_names = $reg_uninstall_key.GetSubKeyNames()  

$key_names

 

I noticed the $key_names was not returning all the expected names based on what I see in regedit..... I am really hoping someone can help me with this

Top 25 Contributor
Posts 287
Top Contributor

Both ways returned exacly what I see when I browse the registry.

Do you get any error message?

I would say it's something related to permissions. But not sure.

Top 10 Contributor
Posts 631
Microsoft MVP
Top Contributor

To get to all the VALUES rather than KEYS, use this:

get-itemproperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'

Or this:

get-itemproperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, UninstallString | Where-Object { $_.DisplayName }

Top 100 Contributor
Posts 32

Thanks for the reply guys. I appreciate it.  That certainly helps, but I just realized the return on those same commands is different whether I do it from a 32bit powershell window or a 64bit window. 

 

It seems like from the 32bit version it always pulls from the software\Wow6432Node\ folder instead of the software\microsoft  folder

Can anyone else confirm this to make sure I am not just losing my mind over this?

 

 

Thanks for the help guys

Top 10 Contributor
Posts 631
Microsoft MVP
Top Contributor

that is normal behavior.

32bit applications on a 64bit machine can only "see" a subset of the registry. That's what you are experiencing when you run the code from a 32bit PS on a 64bit machine.

Top 100 Contributor
Posts 32

Awesome, Thanks!

Not Ranked
Posts 2

Hi,

I am trying to use the following to get a listing of all ACL information of all folders & sub-folders from a specific path but notice that the results tend to skip some sub-folders. I have then compared the security of the listed and "missing" folders and I have full access to them...

Any advise? Appreicate your help!

 

get-childitem "d:\prod\*" -recurse |where-object{($_.PsIsContainer)} |get-acl

Regards

KM

 

Top 25 Contributor
Posts 287
Top Contributor

Hi,

It's something with the characters that compose the folder's name.

But you can get the same result better format with this:

Get-ChildItem D:\Prod -recurse | % {if($_.PsIsContainer){Write $_, $_.GetAccessControl()}} | fl -Property Name, AccessToString

Cheers

Not Ranked
Posts 2

Hi Felipe,

 

The revised code work! Thanks.

 

Can I check if it can be further enhanced to show full path name of the folder & sub-folder instead of just the name of it? Thanks, once again.

appreciate your help.

 

Regards

KM

 

Top 25 Contributor
Posts 287
Top Contributor

No problem, just replace the Name, AccesstoString with FullName, AccesstoString

Cheers

Page 1 of 1 (10 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.