Quantcast
Channel: psappdeploytoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1769

New Post: Set-ActiveSetup and Remove-ActiveSetup: Per-user changes (as requested) Part2

$
0
0
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"
}

Viewing all articles
Browse latest Browse all 1769

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>