Windows Powershell ISE (As Administrator with two ps1-files)

Home Forums Scripting PowerShell Windows Powershell ISE (As Administrator with two ps1-files)

Tagged: 

This topic contains 5 replies, has 3 voices, and was last updated by JeremyW JeremyW 6 months, 4 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • dreivilo47
    dreivilo47
    Participant
    #614153

    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?

    Avatar
    wullieb1
    Moderator
    #614212

    Start-Process -FilePath powershell_ISE.exe “C:\Test\Test1.ps1,C:\Test\Test2.ps1”

    The NoProfile option doesn’t work.

     

    dreivilo47
    dreivilo47
    Participant
    #614221

    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!

    Avatar
    wullieb1
    Moderator
    #614242

    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.

    dreivilo47
    dreivilo47
    Participant
    #614301

    No problem wullieb1, this happens sometimes.
    Thank you again.
    Have a nice day and weekend!

    JeremyW
    JeremyW
    Moderator
    #614421

    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. :)

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.