Have you ever had to run powershell script in a new console window with your for example admin account?
param (
[Parameter(Mandatory=$true)]
[string]$command
)
runas /user:domain\user_name "powershell.exe -noExit -command $command"
I have that saved as “run-powershel_command.ps1”
usage:
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.