Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View Tinus IT Wiki

View my Photo Website

Read Value from Registry

published: April 28, 2019 author: Tinu tags: PowerShell categories: PowerShell-Registry


Table of Contents

Copy items from a local to a remote computer using a psremote-session.

Read Single-Value from Registry

function Get-RegistryValue {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$false)]
        [Object]$args
    )
    $ret = $null
    if(Test-Path "$($args.Hive):\$($args.Path)"){
        Try{
            $ret = Get-ItemPropertyValue -Path "$($args.Hive):\$($args.Path)" -Name $args.Property
        }
        catch{
            $ret = $null
        }
    }
    return $ret
}

$params = @{
    Hive     = 'HKLM'
    Path     = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
    Property = 'ReleaseId'
}

return (Get-RegistryValue -args $params)

Read Values from all Users

$ErrorActionPreference = 'SilentlyContinue'

if(-not(Get-PSDrive -Name 'HKU')){
    New-PSDrive HKU Registry HKEY_USERS
}

$path = '\Control Panel\International'

Get-ChildItem "HKU:\" | ForEach {
    if (Test-Path "HKU:\$($_.Name)\$($path)"){
        @{"$($_.Name)" = "$(Get-ItemPropertyValue "HKU:\$($_.Name)\$($path)" -Name "LocaleName")"}
        if($error){
            $error.Clear()
        }
    }
}

See also

Get-ItemPropertyValue on Microsoft Docs.


← Previous Post [ Top ] Copyright © 2024 by tinuwalther [ Blog ] Next Post →