I use the following code to open two files in Powershell ISE:
powershell_ise.exe -File “C:\test\test1.ps1,C:\test\test2.ps1” -NoProfile
But… how can I open the Powershell ISE as Administrator and then open the two files?
Start-Process -FilePath powershell_ISE.exe “C:\Test\Test1.ps1,C:\Test\Test2.ps1”
The NoProfile option doesn’t work.
Thank you for your answer/solution wullieb1.
You have forgotten “-Verb RunAs” to run it as administrator.
So, the full line is:
Start-Process -FilePath powershell_ise.exe -ArgumentList “C:\test\test1.ps1,C:\test\test2.ps1” -Verb RunAs
Thank you very much for your support wullieb1, my problem is solved!
Yep sorry i thought i had copied it verbose after testing it would definitely work but i obviously missed it.
Glad it resolved your issue.
No problem wullieb1, this happens sometimes.
Thank you again.
Have a nice day and weekend!
There’s several ways to accomplish this with the noprofile option. From powershell:
Start-Process -FilePath powershell_ise.exe -ArgumentList “-File”,”C:\test\test1.ps1,C:\test\test2.ps1″,”-NoProfile” -Verb RunAs
From command prompt:
RunAs /User:domain\username “powershell_ise.exe \”C:\test\test1.ps1,C:\test\test2.ps1\” -NoProfile”
Note the backslash to escape the double quotes used in the arguments.
Of course there’s more ways to do it too. :)
You must be logged in to reply to this topic.
Create a free account today to participate in forum conversations, comment on posts and more.