Skip to content

Test-RunningAsAdmin

SYNOPSIS

Check if the current PowerShell session is running with administrative privileges.

SYNTAX

Test-RunningAsAdmin

DESCRIPTION

This function checks whether the current PowerShell session is running as an administrator by verifying if the user belongs to the Administrators group (SID: S-1-5-32-544). If an error occurs during the check, it writes the exception to the error stream.

EXAMPLES

EXAMPLE 1

Test-RunningAsAdmin

Returns `True` if the session is running as an administrator, otherwise `False`.

PARAMETERS

INPUTS

OUTPUTS

NOTES