winutil/functions/private/Get-WinUtilRegistry.ps1

33 lines
845 B
PowerShell

function Get-WinUtilRegistry {
<#
.SYNOPSIS
Gets the value of a registry key
.EXAMPLE
Get-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0"
#>
param (
$Name,
$Path,
$Type,
$Value
)
Try{
$syscheckvalue = Get-ItemPropertyValue -Path $Path -Value $Value # Return Value
}
Catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
}
Catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
}
Catch{
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}