$cs.Reg_GetInteger
Description
Section titled “Description”Reads a numeric (DWORD/QWORD) registry value. Returns a nullable long, so $null is returned if the value doesn’t exist or can’t be parsed as a number — always check for $null before using the result.
Syntax
Section titled “Syntax”$cs.Reg_GetInteger(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.
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”Nullable long. $null if the value doesn’t exist or isn’t numeric.
Example
Section titled “Example”$enable64Bit = $cs.Reg_GetInteger('HKLM', 'SOFTWARE\Microsoft\.NETFramework', 'Enable64Bit')if ($null -ne $enable64Bit -and $enable64Bit -eq 1){ $cs.Job_WriteLog("64-bit JIT is enabled")}Reading a version-as-DWORD marker written by a previous install and comparing it against the version being installed now, guarding against $null when the marker was never set.
$installedBuild = $cs.Reg_GetInteger('HKLM', 'SOFTWARE\Contoso\AppSuite', 'BuildNumber')if ($null -eq $installedBuild){ $cs.Job_WriteLog("No previous build recorded, treating as a fresh install")}elseif ($installedBuild -lt 4500){ $cs.Job_WriteLog("Upgrading from build $installedBuild")}Reading a feature-flag DWORD to decide whether an optional install step should run.
$reportingEnabled = $cs.Reg_GetInteger('HKLM', 'SOFTWARE\Contoso\AppSuite\Features\Reporting', 'Enabled')if ($reportingEnabled -eq 1){ $cs.Job_WriteLog("Reporting feature is enabled, installing reporting components")}