<# ---------------------------------------------------------------------------- # Version: # Created by: # Created on: # Updated on: # Script Function: ---------------------------------------------------------------------------- #> <# edit below this line! #> $physicalmem=get-wmiobject Win32_ComputerSystem | % {$_.TotalPhysicalMemory} $Physicalmem1=[math]::Round($physicalmem / 1048576) $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges; $computersys.AutomaticManagedPagefile = $False; $computersys.Put(); $pagefile = Get-WmiObject -Query "Select * From Win32_PageFileSetting Where Name like '%pagefile.sys'"; $pagefile.InitialSize = 1024; $pagefile.MaximumSize = $Physicalmem1*1.5; $newpagefile=$pagefile.Put(); $confirmation=Read-host "Do you want to Restart the server (Y/N)" if($confirmation -eq 'N'){ Write-host "The system restart is skipped by the user" -BackgroundColor DarkRed } Else{ Write-Host "The system will be restarting ...." -BackgroundColor DarkGreen Restart-Computer -Force }