$cs.Reg_GetMultiString
Description
Section titled “Description”Reads a REG_MULTI_SZ (multi-string) registry value. Throws an error if the key or the value doesn’t exist, or if the value isn’t a REG_MULTI_SZ. Check the value with $cs.Reg_ExistVariable first when it might be missing.
Syntax
Section titled “Syntax”$cs.Reg_GetMultiString(string registryroot, string regkey, string regvalue)
Parameters
Section titled “Parameters”registryroot (String)
Section titled “registryroot (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.
regkey (String)
Section titled “regkey (String)”Registry key path containing the value, relative to registryroot.
regvalue (String)
Section titled “regvalue (String)”Name of the value to retrieve. Pass "" for the key’s default value.
Return value
Section titled “Return value”String array (string[]) with one element per line of the value.
Example
Section titled “Example”$dependencies = $cs.Reg_GetMultiString('HKLM', 'SYSTEM\CurrentControlSet\Services\W3SVC', 'DependOnService')foreach ($dependency in $dependencies) { $cs.Job_WriteLog("W3SVC depends on service: $dependency")}Reading a list of installed components written by a previous install so the uninstaller knows which per-component keys to remove.
if (-not $cs.Reg_ExistVariable('HKLM', 'SOFTWARE\Contoso\AppSuite', 'InstalledComponents')){ $cs.Job_WriteLog("No component list found, nothing to uninstall")}else{ $installedComponents = $cs.Reg_GetMultiString('HKLM', 'SOFTWARE\Contoso\AppSuite', 'InstalledComponents') foreach ($component in $installedComponents) { $cs.Job_WriteLog("Removing component: $component") $cs.Reg_DelTree('HKLM', "SOFTWARE\Contoso\AppSuite\Components\$component") }}Checking whether a specific dependency was recorded in a multi-string list of prerequisites before continuing.
if ($cs.Reg_ExistVariable('HKLM', 'SOFTWARE\Contoso\AppSuite', 'Prerequisites')){ $prereqs = $cs.Reg_GetMultiString('HKLM', 'SOFTWARE\Contoso\AppSuite', 'Prerequisites') if ($prereqs -contains 'VCRedist2015-2022-x64') { $cs.Job_WriteLog("Required VC++ Redistributable is already recorded as installed") }}