You can script the placement of the Windows page file in your SCCM Task Sequence. Sure you could use the good old wmic pagefileset but we’re in 2014, Powershell is your new friend!

SCCM Task Sequence Page File Location Script

My clients needed a script that :

  • Disable page file on OS drive
  • Move it to D:
  • Set the page file based on the allocated memory installed (x1.5)

I used a Powershell module found here.

My Script then uses a function of this modules to fits my needs. Save this script in a .ps1 file.

#Reads the physical memory and multiplies it by 1.5

$PageFileSizeMB = [Math]::Truncate(((Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

#Sets a Page File of 1.5 * Installed Physical Memory on D: drive
Set-OSCVirtualMemory -InitialSize $PageFileSizeMB -MaximumSize $PageFileSizeMB -DriveLetter “D:”

#Disable page file on C: drive
Set-OSCVirtualMemory -None -DriveLetter “C:”

#–end—

**You can change the values for the drives and the size of the page file.

For the SCCM part :

  • Create a package containing both the .psm1 module and YourScript.ps1
  • Replicate to your DP
  • Create a “Run Command Line” in your Task Sequence. Rename it to “Copy Set Page File Script Locally”
    • Command : xcopy.exe .\*.* C:\OSDPageFile /s /i /y
    • Point to your previously created package
  • Create a “Run Command Line” in your Task Sequence. Rename it to “Set Page File”
    • Command : powershell -command “import-module C:\OSDPageFile\AdjustVirtualMemoryPagingFileSize.psm1; C:\OSDPageFile\SetPageFile.ps1”
  • Place the steps in your customization steps (usually near the end of the TS)

Verify in Windows once the TS completes. You SCCM Task Sequence Page File Location should be changed

Comments (7)

yimesgen

05.26.2017 AT 03:56 PM
Very helpful. Thank you!!!!

Jean-Sebastien

03.03.2016 AT 11:53 AM
I tried this script. The script itself work, but when running during the TS, it doesn't work. When the TS is finished, I reboot to be sur everything is set and Pagefile is still managed by windows, so not using the script value. I have to run the script again. I tried running the script as the last item in the TS, still didn'T work 🙁

Bruce

10.05.2015 AT 11:13 PM
Did anyone get this to work? Looks like on the first command there's an extra "." before the first wild character "*" xcopy.exe .*.* C:OSDPageFile /s /i /y On the next one looks like it's missing a few slashes? powershell -command “import-module C:OSDPageFileAdjustVirtualMemoryPagingFileSize.psm1; C:OSDPageFileSetPageFile.ps1”

Benoit Lecours

10.09.2015 AT 06:37 AM
Thnaks for pointing that out. A cut and paste problem from our previous blogging platform. I'll update the command in the post.

Jean-Sebastien

02.09.2016 AT 08:11 AM
It still missing a slash Original: powershell -command “import-module C:\OSDPageFile\AdjustVirtualMemoryPagingFileSize.psm1; C:\OSDPageFileSetPageFile.ps1” Check the 2nd part Original: powershell -command “import-module C:\OSDPageFile\AdjustVirtualMemoryPagingFileSize.psm1; C:\OSDPageFile \ SetPageFile.ps1”

Benoit Lecours

02.09.2016 AT 10:25 AM
Updated ! Thanks.

Jag Nagra

12.08.2014 AT 03:20 AM
Excellent - thank you.