Written by 6:00 pm Microsoft, PowerShell, Windows, Windows Server • 2 Comments

Powershell: Changing registry key value

Powershell Header

After posting Pagefile size bigger than 4095MB on Windows Server 2003 I had the Idea to change this registry values with powershell.

  1. First start powershell
  2. You can get all PS Drives with the command
    Get-PSDrive

    Get-PSDrive

  3. Now you see the drive HKLM which stands for HKEY_LOCAL_MACHINE
  4. Open this Registry Key
    Set-Location 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management'
  5. With this command you get all the key values
    Get-ItemProperty -path .
  6. With the next command you can set the the key value
    Set-ItemProperty -path . -name "PagingFiles" -value "D:\pagefile1\pagefile.sys 4096 4096"

And now the simple way with multiple entries:

$values = @"
D:\pagefile1\pagefile.sys 4096 4096
D:\pagefile2\pagefile.sys 4096 4096
"@
$keys = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
$name = "PagingFiles"
Set-ItemProperty -path $keys -name $name -value $values

Tags: , , , , , , , , , , , , , , , Last modified: January 7, 2019
Close Search Window
Close