Sometimes, a script may need to run a command that needs elevation (Administrator privileges).
Instead of requiring the script to run with full privileges altogether, you can also send individual commands to an elevated shell.
This will restart the Spooler driver (which requires elevated privileges), and sends the command to another PowerShell process. It will automatically start elevated if the current process does not have Administrator privileges.
$command = 'Restart-Service -Name spooler' Start-Process -FilePath powershell.exe -ArgumentList "-noprofile -command $Command" `
-Verb runas