PowerShell file run with admin rights


  1. Posts : 37
    Windows 10
       #1

    PowerShell file run with admin rights


    I made a script in PowerShell and I have to run with admin rights.
    I also made a shortcut of that file and with right click -> properties, shortcut tab -> advanced -> run as admin is disabled.

    How can I run a ps1. file (PowerShell file) with admin rights ? (see picture)
    Attached Thumbnails Attached Thumbnails PowerShell file run with admin rights-screenshot-51-.png  
      My Computer


  2. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #2

    Hello @kinderu81,

    kinderu81 said:
    How can I run a ps1. file (PowerShell file) with admin rights ?

    Have a look at this . . .

    > How to Add "Open PowerShell window here as administrator" context menu in Windows 10

    I hope this helps.
      My Computer


  3. Posts : 16,978
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #3

    kinderu81 said:
    I made a script in PowerShell and I have to run with admin rights.
    I also made a shortcut of that file and with right click -> properties, shortcut tab -> advanced -> run as admin is disabled.
    Right-click on your shortcut, select Properties.
    In the target field write this before the existing text
    Code:
    powershell.exe
    PowerShell file run with admin rights-ps-shortcut.png

    It will now let you click on the Advanced button and set the checkbox for Run as Admin.

    Don't be concerned later on when you see that Windows has automatically added the full path to powershell.exe in that Target field. It will make no difference to you or your shortcut.

    Denis
      My Computer


  4. Posts : 37
    Windows 10
    Thread Starter
       #4

    Try3 said:
    Right-click on your shortcut, select Properties.
    In the target field write this before the existing text
    Code:
    powershell.exe
    PowerShell file run with admin rights-ps-shortcut.png

    It will now let you click on the Advanced button and set the checkbox for Run as Admin.

    Don't be concerned later on when you see that Windows has automatically added the full path to powershell.exe in that Target field. It will make no difference to you or your shortcut.

    Denis
    It works Try3, thank you!
      My Computer


  5. Posts : 623
    Windows 10 Pro
       #5

    Try3 said:
    Right-click on your shortcut, select Properties.
    In the target field write this before the existing text
    Code:
    powershell.exe
    PowerShell file run with admin rights-ps-shortcut.png

    It will now let you click on the Advanced button and set the checkbox for Run as Admin.

    Don't be concerned later on when you see that Windows has automatically added the full path to powershell.exe in that Target field. It will make no difference to you or your shortcut.

    Denis
    I was looking everywhere on how to enable the "Run as Administrator" option for a PowerShell shortcut.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:15.
Find Us




Windows 10 Forums