Running the PowerShell Process as Administrator
There are key functions/actions that cannot be taken within Windows without the use of an Administrator account of sorts, whether that is the local administrator, domain administrator or enterprise administrator. All of which have raised privileges to complete their actions. To open a new PowerShell window with administrative rights, use the following command:
· Start-Process Powershell -Verb runAs
Checking PowerShell is being run with Administrative Rights
We can use the .NET functionality within PowerShell to check if the current session is matching the rights of an Administrator on the system.
To check what privileges the PowerShell window is running at, use the following:
· ([Security.Principal.WindowsPrincipal]` [Security.Principal.WindowsIdentity]::GetCurrent() ` ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)