Skip to content

$cs.Reg_GetMultiString

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.

$cs.Reg_GetMultiString(string registryroot, string regkey, string regvalue)

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.

Registry key path containing the value, relative to registryroot.

Name of the value to retrieve. Pass "" for the key’s default value.

String array (string[]) with one element per line of the value.

Terminal window
$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.

Terminal window
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.

Terminal window
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")
}
}

$cs.Reg_GetString $cs.Reg_GetInteger $cs.Reg_ExistVariable