You are currently viewing PowerShell Script to delete a string from the registry.

PowerShell Script to delete a string from the registry.

One of my co-workers was having trouble accessing customer’s Citrix Workspace. Working with the customer’s support, she was told to uninstall Citrix Workspace and reinstall it but she was unable to uninstall it. Towards the end of the uninstallation process, it bombed on her with an error. I tried to restore the Windows to its previous version but still was having an issue. I thought it might have something to do with the registry entries. I decided to search the registry for all the occurrence of a string with “Citrix” and delete it. I was able to uninstall the Citrix after that.

Here is the PowerShell script to exactly do that:

# Get the list of registry keys related to Citrix Workspace
$registryKeys = Get-ChildItem -Path HKLM:\Software\Wow6432Node\Citrix -Recurse

# Loop through each registry key and delete it
foreach ($registryKey in $registryKeys)
{
    Write-Host "Deleting registry key: $($registryKey.PSPath)"
    Remove-Item -Path $registryKey.PSPath -Force
}