Question: I am running a script that queries windows and its registry.
I'm trying to add a code where it can query both 64bit and 32bit versions of the OS.

So if it's a 32bit then it should look at HKLM\_SOFTWARE\_TEAMVIEWER
and if it's 64bit it should query at HKLM\_SOFTWARE\_WOW6432Node\_Teamviewer

So, how should this part look to query both locations depending on OS type?

```
$TVID = (Get-ItemProperty "HKLM:\SOFTWARE\TeamViewer").ClientID

```

This is the script:

```
    Param(
 [string]$ServerShare
)

$dom = $env:userdomain
$usr = $env:username
$Fullname = ([adsi]"WinNT://$dom/$usr,user").fullname

$TVID = (Get-ItemProperty "HKLM:\SOFTWARE\TeamViewer").ClientID
if (!$TVID) { $TVID = (Get-ItemProperty "HKLM:\SOFTWARE\TeamViewer\Version9").ClientID }

```

Answer: 
Apart from first detecting what bitness the computer uses, there is a simpler way I think by testing any of the two possible registry paths like:

```
# get the existing registry path (if any)
$regPath = 'HKLM:\SOFTWARE\TeamViewer', 'HKLM:\SOFTWARE\WOW6432Node\TeamViewer' | Where-Object { Test-Path -Path $_ }
if ($regPath) { 
    # we found the path, get the ClientID value
    $TVID = (Get-ItemProperty -Path $regPath).ClientID
}
else { 
    Write-Warning "TeamViewer registry path not found"
}

```
The easiest way to check OS bittness is to use .net.

```
[Environment]::Is64BitOperatingSystem

```