added new Get-TeamViewerInstallationType function#96
added new Get-TeamViewerInstallationType function#96radu-cristea-15 wants to merge 1 commit intomainfrom
Conversation
bfd0667 to
8c7e2bb
Compare
8c7e2bb to
269f65d
Compare
|
|
||
| ## SYNOPSIS | ||
|
|
||
| Gets the TeamViewer installation type. |
There was a problem hiding this comment.
| Gets the TeamViewer installation type. | |
| Returns the TeamViewer installation type. |
|
|
||
| ## DESCRIPTION | ||
|
|
||
| The command checks the TeamViewer installation and returns the installation type (Msi or Exe). |
There was a problem hiding this comment.
| The command checks the TeamViewer installation and returns the installation type (Msi or Exe). | |
| The command checks the TeamViewer installation and returns the installation type (Msi, Exe, or Unknown). |
There was a problem hiding this comment.
Running all tests returned this:
[-] Get-TeamViewerInstallationType.TeamViewer not installed.Should return Unknown when TeamViewer is not installed 11.62s (11.62s|1ms)
Expected strings to be the same, but they were different.
Expected length: 7
Actual length: 3
Strings differ at index 0.
Expected: 'Unknown'
But was: 'Msi'
^
at $result | Should -Be 'Unknown', D:\Sources\TeamViewerPS\Tests\Public\Get-TeamViewerInstallationType.Tests.ps1:60
at <ScriptBlock>, D:\Sources\TeamViewerPS\Tests\Public\Get-TeamViewerInstallationType.Tests.ps1:60
Please investigate what is going wrong here.
| @@ -0,0 +1,68 @@ | |||
| function Get-TeamViewerInstallationType { | |||
|
|
|||
| #i) | |||
There was a problem hiding this comment.
| #i) |
Unneccessary comment, I think.
| } | ||
| } | ||
|
|
||
| #ii) |
There was a problem hiding this comment.
| #ii) |
Obsolete comment can be removed.
| 'HKLM:\SOFTWARE\WOW6432Node\TeamViewer' | ||
| ) | ||
|
|
||
| foreach ($tv in $tvPaths) { |
There was a problem hiding this comment.
This foreach will always find at least one of the entries when TV is installed and thus at least one of them will call return ''. The second part further down is never called. This should not be the case as the second check should also be made.
| } | ||
| } | ||
| catch { | ||
| return 'Exe' |
There was a problem hiding this comment.
I am not really sure, if the catch should return "Exe". It looks more like "Unknown" to me.
|
|
||
| #ii) | ||
| try { | ||
| $msi = Get-CimInstance Win32_Product -Filter "Name='TeamViewer'" -ErrorAction Stop |
There was a problem hiding this comment.
This test should be done above when it seems likely that the installation is an MSI installation. Both MsiInstallation registry value + this being present are proof of the correct installation via MSI.
| 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall', | ||
| 'HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall' | ||
| ) | ||
| foreach ($path in $uninstallPaths) { |
There was a problem hiding this comment.
This test would make more sense above when we believe it is not Msi but quiet likely an Exe installation. Then we could add a check, that the file pointed to by the UninstallString is really on the disc. If that file is missing, it is definitely a broken installation and should return "Unknown".
No description provided.