Private/Helper/Test-AdministratorElevation.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Test-AdministratorElevation { <# .SYNOPSIS Checks if the current user has administrative privileges. .DESCRIPTION This function determines whether the current user is running with administrative privileges. .PARAMETER None This function does not take any parameters. .EXAMPLE Test-AdministratorElevation Checks if the current user has administrative privileges and returns $True or $False. .NOTES The function uses WindowsPrincipal and WindowsIdentity to check the user's role. #> [CmdletBinding()] PARAM ( ) IF (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` [Security.Principal.WindowsBuiltInRole] "Administrator")) { RETURN $True } RETURN $False } |