Registry Subkey Count In Powershell

What is the correct syntax for getting a registry subkey count in Powershell, and if that count passes the If statement, then continue.
I am testing this to see if an Outlook profile has not been setup on this computer than continue, otherwise end script

Here is what I have so far:

Get-ChildItem "hkcu:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
[string]$regKeys = Get-ChildItem "hkcu:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"

If ($regKeys._GetSubKeyCount -lt 5)
      {      
            'Outlook is setup on this computer'
}
Else
      {      
            'Outlook is not setup on this Computer'
}




I don't believe that I have the ._GetSubKeyCount syntax correct. Please advise.
MGS-TECHAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jostranderCommented:
Try this sample:
[string]$regKey = "hkcu:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
$(Get-Item $regKey).subkeycount

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
illtbaguCommented:
Strange way to do things. It's been a couple of years since I managed exchange server but outlook should do all of this for you. I guess your probably not on exchange. Anyways maybe this might be a better way of doing things
$user = [Environment]::UserName

$foo = Get-ChildItem "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" -recurse -ErrorAction SilentlyContinue `
| ForEach-Object {get-itemproperty -Path $_.PsPath} `
| where {$_."001e6603" -match "$user"}

if ($foo -ne $null) {Write-Host "Outlook profile seems to exist for user $user, abort"} else {Write-Host "No Outlook profile found for $user starting process..."}

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.