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

Related Posts:

One thought on “Powershell: Changing registry key value

  1. Pingback: Pagefile size bigger than 4095MB on Windows Server 2003 | thomasmaurer.ch

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>