Assert-AdminPrivilege

Writes an error and returns false if the user doesn't have administrator privileges.

Syntax

Assert-AdminPrivilege [<CommonParameters>]

Description

Many scripts and functions require the user to be running as an administrator. This function checks if the user is running as an administrator or with administrator privileges and writes an error if the user doesn't.

Related Commands

EXAMPLE 1

Assert-AdminPrivilege

Writes an error that the user doesn't have administrator privileges.