PowerShell – Run script in new console window

Have you ever had to run powershell script in a new console window with your for example admin account?

param (
runas /user:domain\user_name "powershell.exe -noExit -command $command"

I have that saved as “run-powershel_command.ps1

run-powershell_command.ps1 "get-aduser bob"

this will ask you for the password for the hardcodded username once that is provided it will open new window and execute the command.