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:”
**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
Very helpful. Thank you!!!!
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 🙁
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”
Thnaks for pointing that out. A cut and paste problem from our previous blogging platform. I’ll update the command in the post.
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”
Updated ! Thanks.
Excellent – thank you.