$cs.Reg_DeleteVariable
Description
Section titled “Description”Deletes a single named value from a registry key, leaving the key itself in place. Pass an empty string "" as regvalue to delete the key’s unnamed default value.
If the key or the value doesn’t exist, nothing happens. If the value can’t be deleted, for example because access is denied, the failure is written to the log and the function doesn’t raise an error.
Syntax
Section titled “Syntax”$cs.Reg_DeleteVariable(string regroot, string regpath, string regvalue)
Parameters
Section titled “Parameters”regroot (String)
Section titled “regroot (String)”Root hive: HKLM/HKEY_LOCAL_MACHINE, HKCU/HKEY_CURRENT_USER, or HKU/HKEY_USERS. PowerPacks run as SYSTEM, so HKCU is the SYSTEM account’s hive, not the logged-on user’s. To change user settings, see Invoke-RunAsLoggedOnUser.
regpath (String)
Section titled “regpath (String)”Registry key path containing the value, relative to regroot.
regvalue (String)
Section titled “regvalue (String)”Name of the value to delete. Pass "" to delete the key’s default (unnamed) value.
Return value
Section titled “Return value”None.
Example
Section titled “Example”if ($cs.Reg_ExistVariable('HKLM', 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'Everything')){ $cs.Reg_DeleteVariable('HKLM', 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'Everything')}Removing a single stale setting value during PostInstall cleanup, without touching the rest of the key.
$cs.Reg_DeleteVariable('HKLM', 'SOFTWARE\Contoso\AppSuite', 'LegacyLicenseServer')$cs.Job_WriteLog("Removed obsolete LegacyLicenseServer setting")Deleting a key’s default (unnamed) value by passing "" as regvalue, leaving all other named values in place.
$cs.Reg_DeleteVariable('HKLM', 'SOFTWARE\Classes\.contoso', '')