-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial commit of the Windows uninstall script #610
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey I tested this just now. Two thoughts:
The script does tell me that the uninstall Key does not exist. And I believe it's due to the fact that the uninstall key looks something like this:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{E14D51FF-380F-4964-9581-665DED7F58C1}
Where curly braces encase the GUID key.
Though everything seems to be removed I think the messaging is confusing here.
FWIW my registry keys were as follows:
`Computer\HKEY_CLASSES_ROOT\Installer\Products\FF15D41EF0834694591866D5DEF7851C
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\FF15D41EF0834694591866D5DEF7851C
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{E14D51FF-380F-4964-9581-665DED7F58C1}
Computer\HKEY_LOCAL_MACHINE\Software\JumpCloud
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\FF15D41EF0834694591866D5DEF7851C`
I'm curious if you are seeing the same verbose messaging @ecourtneyjc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Ed, thanks for the work here. I added some review points. Couple things that pop up from my tests is:
- Find-JumpCloudGUID gets both JCAGent GUID and MSI installation ID. It should be separated since it get's called and looped through
Remove-JumpCloud
function which results on some errors.
New-PSDrive -Name "HKCR" -PSProvider Registry -Root "HKEY_CLASSES_ROOT" -ErrorAction SilentlyContinue | ||
|
||
# Function to recursively search for DisplayName in the registry | ||
function Find-JumpCloudGUID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the value with brackets MSI installation ID? It looks like it from HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall<JC MSI Installation ID>
. If so, pulling the MSI installation ID should be in a separate function from Find-JumpCloudGUID.
} | ||
} | ||
|
||
# Stopping and removing the service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should Stop-Service be before removing reg keys? A running agent might mess with key removals
function Remove-JumpCloud { | ||
$guids = Find-JumpCloudGUID | ||
|
||
foreach ($guid in $guids) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got GUID and MSI Install ID when I ran Find-JumpCloudGUID
. Both should not be looped together.
|
||
# Stopping and removing the service | ||
$serviceName = "jumpcloud-agent" | ||
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (Test-Path $key) { | ||
Remove-Item -Path $key -Recurse -Force -Verbose -ErrorAction SilentlyContinue | ||
} else { | ||
Write-Host "Registry key $key not found." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issues
What does this solve?
Gives support and customers a script to automatically remove broken Windows agent installs.
Is there anything particularly tricky?
Since the GUID used in the registry to identify the current installation is random, discovery of the JC Agent GUID is done via recursive search through 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products' to obtain the ID used to remove the remaining keys.
How should this be tested?
Install the JumpCloud Windows Agent
Confirm the existence of the following registry entries
Run the UninstallWindowsAgent.ps1 script as an administrator.
Verify the above keys are removed
Verify the JumpCloud Agent service is no longer present.
Verify that the JumpCloud Agent folder is empty aside from:
Reinstall Windows Agent using preferred method.
Confirm agent reinstall is successful.
Screenshots