How do I know if PowerShell is running as administrator?

How do I know if PowerShell is running as administrator?
Answer
All that’s left to do is call the function to check whether the user is an admin. We can use an IF statement with the -NOT operator to call the function and throw an error to stop the script if the user isn’t an administrator. If the user is an administrator, PowerShell will continue and run the rest of your script.
 

Tìm kiếm

Back
Top