Posts are limited to 10000. ("Content has been shortened to 10000 characters.")
Function Remove-ActiveSetup {
<#
.SYNOPSIS
Remove an Active Setup entry in the registry
.DESCRIPTION
Version: 0.5 - Author: CodePlex's That_annoying_guy - 2014 Sept 03 - BETA USE AT YOUR OWN RISK!!
Active Setup is a built-in feature of Windows to handle per-user changes
A registry key is created in HKLM and *as users login*, the user runs the "Stub" in the StubPath value and copies the Version value to HKCU in a matching Key
If the Version value in HKLM is higher than the version value in HKCU, the StubPath is ran again when a user logs in.
-Removes Active Setup Key from HKLM. Does NOT touch Active Setup Keys in HKCU unless you use -purge
-This is complimentary to Set-ActiveSetup
.LINK
http://www.sepago.de/d/helge/2010/04/22/active-setup-explained
.EXAMPLE
Remove-ActiveSetup [-Key "MyCustomKeyName"] [-Purge]
Remove-ActiveSetup -Key "MyCustomKeyName"
Remove-ActiveSetup -Purge
.PARAMETER -Key
-Optional Name of registry Key name used for the Active Setup.
-Defaults to $installName if blank
.PARAMETER -Purge
-Will load each HKCU hive (.Dat file) to remove Active setup key
-Not Implemented yet. (TBD if possible)
.NOTES
TBD: [bool]$global:ACTIVESETUP_DISABLE can be used to prevent the Active Setup from being created (Needed?)
TODO: Add 32/64Bit support. (Current version is 64-bit only but I've been told this is important)
.COMPONENT
Depends on TK's Remove-RegistryKey and Write-Log functions
#>
Param(
[string]$Key=$installName,
[switch]$Purge
)
[String]$ActiveSetupKey="HKLM:\Software\Microsoft\Active Setup\Installed Components\$Key"
#CAVEAT: Deprecated feature (Deprecated = May disappear in a future version)
IF ($global:ACTIVESETUP_DISABLE) {
Write-Log "WARNING: ActiveSetup is disabled for this package. Exiting Set-ActiveSetup() function..."
return
}
Write-Log "Removing Active Setup Key $ActiveSetupKey..."
# Remove-RegistryKey -Key $ActiveSetupKey -Recurse $true -ContinueOnError $false #Fails if Key is already deleted = TK Bug
# Remove-RegistryKey -Key $ActiveSetupKey -Recurse $true #Fails if SubKeys do not exist or already deleted = TK Bug
Remove-RegistryKey -Key $ActiveSetupKey
If ($Purge) {
Write-Log "Removing $ActiveSetupKey on all other User hives on machine..."
#TODO: Clean out ActiveSetup Key in each user profile
}
Write-Log "Remove-ActiveSetup done.`n"
}