If a script needs to run only particular commands with full Administrator privileges, you can run those in a separate elevated shell.
$code = "md $env:windir\newfolder | Out-Null" if ((Test-Path $env:windir\newfolder) -eq $false) { Start-Process powershell.exe -Verb RunAs -ArgumentList "-noprofile -windowstyle hidden -command $code" } if ((Test-Path $env:windir\newfolder) -eq $false) { 'Folder still does not exist, something went wrong' } else { 'Folder was created with admin privileges' }