If you would like to programmatically control page file settings, you can use WMI but must enable all privileges using -EnableAllPrivileges. The code below will disable automatic page files:
$c = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges
$c.AutomaticManagedPagefile = $false
$c.Put()
$c.AutomaticManagedPagefile = $false
$c.Put()