Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

powershell test if command is ran as administrator

Crazy Camel answered on March 16, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • powershell admin privileges
  • powershell check if user is admin
  • run powershell command as administrator
  • windows powershell as an admin
  • powershell run as current logged on user
  • run application as administrator with powershell
  • Run PowerShell ISE As Admin
  • powershell t admin
  • how to run powershell without admin rights
  • how to run powershell script as admin
  • powershell script as administrator
  • how to open powershell as administrator

  • powershell test if command is ran as administrator

    0

    Use the following PowerShell syntax to determine whether your command or function is being executed with administrator privileges:

    / Copy pasted from source /

    Breaking apart what this does:

    [bool] - Cast the end result to a bool.

    [System.Security.Principal.WindowsIdentity]::GetCurrent() - Retrieves the WindowsIdentity for the currently running user.

    (...).groups - Access the groups property of the identity to find out what user groups the identity is a member of.

    -match "S-1-5-32-544" checks to see if groups contains the Well Known SID of the Administrators group, the identity will only contain it if "run as administrator" was used. 

    Popularity 1/10 Helpfulness 1/10 Language shell
    Source: superuser.com
    Link to this answer
    Share Copy Link
    Contributed on Mar 16 2023
    Crazy Camel
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.