How to change several system settings with PowerShell

PowerShell is an awesome addition to Windows and the admins that administer servers.  This post covers a few PowerShell commands to make changes to common settings.

Create a drive to HKEY_CLASSES_ROOT & HKEY_CURRENT_USER. By default these two registry geys are not available for mounting and using in PowerShell, but that is an easy fix!

if (!(get-psdrive hkcr -ea 0)){New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | out-null}
 if (!(get-psdrive hku -ea 0)){New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS | out-null}


How about disabling UAC (User Access Control?

 $regkeypath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
 Set-ItemProperty -Path $regkeyPath -Name "EnableLUA" -Value 0

Let’s set a few  Startup and Recovery Options.

 #Write Debugging Info
 Set-ItemProperty -Path $regkeypath -Name "CrashDumpEnabled" -Value 3
 #System Failure Auto Reboot
 Set-ItemProperty -Path $regkeypath -Name "AutoReboot" -Value 3
 #System Failure Write to Event Logs
 Set-ItemProperty -Path $regkeypath -Name "LogEvent" -Value 3

Want to disable some services? Here is a way to disable four.

$regkeypath = "HKLM:\System\CurrentControlSet\Services"
 Set-ItemProperty -Path $regkeypath\RasMan -Name "Start" -Value 3
 Set-ItemProperty -Path $regkeypath\Tapisrv -Name "Start" -Value 4
 Set-ItemProperty -Path $regkeypath\RasAuto-Name "Start" -Value 4
 Set-ItemProperty -Path $regkeypath\RemoteAccess -Name "Start" -Value 4

Screen Saver Password Protection

$regkeypath1 = "HKU:\.DEFAULT\Control Panel\Desktop"
 $regkeypath2 = "HKCU:\Control Panel\Desktop"
 Set-ItemProperty -Path $regkeypath1 -Name "ScreenSaveActive" -Value 1
 Set-ItemProperty -Path $regkeypath2 -Name "ScreenSaveActive" -Value 1
 Set-ItemProperty -Path $regkeypath1 -Name "ScreenSaverIsSecure" -Value 1
 Set-ItemProperty -Path $regkeypath2 -Name "ScreenSaverIsSecure" -Value 1
 Set-ItemProperty -Path $regkeypath1 -Name "SCRNSAVE.EXE" -Value logon.scr
 Set-ItemProperty -Path $regkeypath2 -Name "SCRNSAVE.EXE" -Value logon.scr

Set Standard Desktop -Logon Screen Saver Timeout Time – in seconds

Set-ItemProperty -Path $regkeypath1 -Name "ScreenSaveTimeout" -Value 900
 Set-ItemProperty -Path $regkeypath2 -Name "ScreenSaveTimeout" -Value 900

Force Classic Start Menu

 $regkeypath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer"
 #Create the key if doesn't exist
 if (!(Test-Path $regkeypath)) {New-Item $regkeypath | Out-Null}
 if ((Get-ItemProperty -Path $regkeypath).NoSimpleStartMenu -eq $null) { New-ItemProperty $regkeypath -Name "NoSimpleStartMenu" -type DWORD | Out-Null}
 Set-ItemProperty -Path $regkeyPath -Name "NoSimpleStartMenu" -Value 1

Standard Desktop -Window Animations

 $regkeypath = "HKU:\.DEFAULT\Control Panel\Desktop\WindowMetrics"
 $regkeyexists = Test-Path $regkeypath
 if ($regkeyexists -eq $false){ New-Item -Path $regkeypath | Out-Null }
if ((Get-ItemProperty -Path $regkeypath).minAnimate -eq $null) { New-ItemProperty $regkeypath -Name "minAnimate" -type DWORD | Out-Null}
 Set-ItemProperty -Path $regkeyPath -Name "minAnimate" -Value 0

Standard Desktop – Automatically End Hung Applications on ShutDown

 $regkeypath = "HKU:\.DEFAULT\Control Panel\Desktop"
 if ((Get-ItemProperty -Path $regkeypath).AutoEndTasks -eq $null){ New-ItemProperty $regkeypath -Name "AutoEndTasks" -type String | Out-Null}
 Set-ItemProperty -Path $regkeyPath -Name "AutoEndTasks" -Value 1

Configure Boot menu time out setting

$sh = New-Object -comobject ""
$BootTimeOut = $"bcdedit /timeout $Global:BootTimeOut",1,"true")

Configure Power Options, set yo High Performance

 $HighPerfPwrGUID = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c"
 $PowerCfgCmd = "powercfg -s $HighPerfPwrGUID"
 $PowerCfg = $$PowerCfgCmd, 1, "true")
if ((Test-Path(Join-Path $env:SystemDrive hiberfil.sys)))
 $turnoffHibernationCmd = "powercfg /h off"
 $HibernationCfg = $$turnoffHibernationCmd, 1, "true")

Hope you find these changes usefull in your daily endeavors!

One Response to “How to change several system settings with PowerShell”

  1. mark_praktisero says:

    this is a good link

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.