Posted On January 26, 2022

PowerShell: Add and Remove a Registry Key

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Add and Remove a Registry Key

How to Add a Registry Key

# Add New Registry Key
$regHive='REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM'
$keyname='OleDbTimeout'
$value=600
Set-ItemProperty -Path $regHive -Name $keyname -value $value

# Validation
Get-ItemProperty $regHive -name $keyname

PS C:\Users\backupadmin> Get-ItemProperty $regHive -name $keyname
OleDbTimeout : 600
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft
PSChildName  : MSCRM
PSProvider   : Microsoft.PowerShell.Core\Registry

How to Remove a Registry Key

# Remove Registry Key
$regHive='REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM'
$keyname='OleDbTimeout'
Remove-ItemProperty -Path $regHive -Name $keyname -value $value

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Disable Windows Hello

function disableWindowsHello{ $regHive='REGISTRY::HKLM\SOFTWARE\Policies\Microsoft\PassportForWork' $refreshEnv=$false if (!(Test-Path $regHive)){ Write-Host "Creating registry path $regHive" New-Item -Path $regHive…

PowerShell: Recover Deleted Active Directory Objects

$domain="kimconnect"$ltd="com"$dc="dc01"$userToRecover="Tom Cruise"# Enable Active Directory Recycle Bin# Enable-ADOptionalFeature 'Recycle Bin Feature' -Scope ForestOrConfigurationSet -Target "$domain.$ltd"…

Linux: How to Set Startup Script

In previous Linux versions, startup scripts can simply be enabled by linking a script into…