Get-TeamViewerID.ps1
function Get-TeamViewerID { <# .SYNOPSIS Short Description .DESCRIPTION Detailed Description .EXAMPLE Get-TeamViewerID explains how to use the command can be multiple lines .EXAMPLE Get-TeamViewerID another example can have as many examples as you like #> [CmdletBinding()] param ( [Parameter(Mandatory=$True, Position=0)] [System.String] $computer = 'localhost' ) <# $sb = { try { (Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\TeamViewer\).ClientID } catch { Write-Warning "No entry found in WOW6432Node. Attempting HKLM\Software\TeamViewer\" (Get-ItemProperty HKLM:\SOFTWARE\TeamViewer\).ClientID } } #> $sb_64 = { (Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\TeamViewer\).ClientID } $sb_32 = { (Get-ItemProperty HKLM:\SOFTWARE\TeamViewer\).ClientID } $ClientID = Invoke-Command -ComputerName $computer -ScriptBlock $sb_64 -ErrorAction SilentlyContinue if ($ClientID -ne $null) {Write-Host TeamViewer ID: $ClientID -ForegroundColor Green -BackgroundColor Black} if ( $error[0].Exception.Message -like '*HKLM:\SOFTWARE\WOW6432Node\*' -or $ClientID -eq $null ) { write-host Error attempting to query WOW6432Node. Attempting 32-bit OS Method. -ForegroundColor White -BackgroundColor DarkBlue $ClientID = Invoke-Command -ComputerName $computer -ScriptBlock $sb_32 -ErrorAction Continue Write-Host TeamViewer ID: $ClientID -ForegroundColor Green -BackgroundColor Black } #$ClientID = Invoke-Command -ComputerName $computer -ScriptBlock $sb return $ClientID } |