OpsaC - Operating as PowerShell code
published: April 28, 2019 author: Tinu tags: PowerShell categories: PowerShell-Registry
Copy items from a local to a remote computer using a psremote-session.
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)
$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()
}
}
}
Get-ItemPropertyValue on Microsoft Docs.