Resolve-UAC.ps1
<#PSScriptInfo .VERSION 1.0 .GUID a02a7cab-50db-416c-99ee-057c13760240 .AUTHOR bollet.thierry@sfr.fr .COMPANYNAME .COPYRIGHT .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES #> <# .SYNOPSIS .DESCRIPTION Resolve UAC for User Object .LINK https://support.microsoft.com/en-us/kb/305144 .EXAMPLE Get-UACState -user <your user> For user UACUSER (cn) : Get-UACState -user UACUSER NORMAL_ACCOUNT/ACCOUNTDISABLE/ Here, the userAccountControl value is 514 512 = NORMAL_ACCOUNT 2 = ACCOUNTDISABLE #> Param() function Get-UACState { Param([Parameter(Mandatory=$true,HelpMessage="Insert Name : ")]$user) $error.clear() $ErrorActionPreference = "Stop" $UAC=(get-aduser -Identity $user -Properties userAccountControl) $valeur=$UAC.userAccountControl switch ($valeur) {({$valeur -eq 100613088}) {$convertvaleur="ALL"} ({$valeur -ge 100613088}) {$valeur=$valeur-100613088;$convertvaleur+="PARTIAL_SECRETS_ACCOUNT/"} ({$valeur -ge 67108864}) {$valeur=$valeur-67108864;$convertvaleur+="TRUSTED_TO_AUTH_FOR_DELEGATION/"} ({$valeur -ge 16777216}) {$valeur=$valeur-16777216;$convertvaleur+="PASSWORD_EXPIRED/"} ({$valeur -ge 8388608}) {$valeur=$valeur-8388608;$convertvaleur+="DONT_REQ_PREAUTH/"} ({$valeur -ge 4194304}) {$valeur=$valeur-4194304;$convertvaleur+="USE_DES_KEY_ONLY/"} ({$valeur -ge 2097152}) {$valeur=$valeur-2097152;$convertvaleur+="DONT_REQ_PREAUTH/"} ({$valeur -ge 1048576}) {$valeur=$valeur-1048576;$convertvaleur+="NOT_DELEGATED/"} ({$valeur -ge 524288}) {$valeur=$valeur-524288;$convertvaleur+="TRUSTED_FOR_DEgeGATION/"} ({$valeur -ge 262144}) {$valeur=$valeur-262144;$convertvaleur+="SMARTCARD_REQUIRED/"} ({$valeur -ge 131072}) {$valeur=$valeur-131072;$convertvaleur+="MNS_LOGON_ACCOUNT/"} ({$valeur -ge 65536}) {$valeur=$valeur-65536;$convertvaleur+="DONT_EXPIRE_PASSWORD/"} ({$valeur -ge 8192}) {$valeur=$valeur-8192;$convertvaleur+="SERVER_TRUST_ACCOUNT/"} ({$valeur -ge 4096}) {$valeur=$valeur-4096;$convertvaleur+="WORKSTATION_TRUST_ACCOUNT/"} ({$valeur -ge 2048}) {$valeur=$valeur-2048;$convertvaleur+="INTERDOMAIN_TRUST_ACCOUNT/"} ({$valeur -ge 512}) {$valeur=$valeur-512;$convertvaleur+="NORMAL_ACCOUNT/"} ({$valeur -ge 256}) {$valeur=$valeur-256;$convertvaleur+="TEMP_DUPLICATE_ACCOUNT/"} ({$valeur -ge 128}) {$valeur=$valeur-128;$convertvaleur+="ENCRYPTED_TEXT_PWD_ALLOWED/"} ({$valeur -ge 64}) {$valeur=$valeur-64;$convertvaleur+="PASSWD_CANT_CHANGE/"} ({$valeur -ge 32}) {$valeur=$valeur-32;$convertvaleur+="PASSWD_NOTREQD/"} ({$valeur -ge 16}) {$valeur=$valeur-16;$convertvaleur+="LOCKOUT/"} ({$valeur -ge 8}) {$valeur=$valeur-8;$convertvaleur+="HOMEDIR_REQUIRED/"} ({$valeur -ge 2}) {$valeur=$valeur-2;$convertvaleur+="ACCOUNTDISABLE/"} ({$valeur -eq 1}) {$valeur=$valeur-1;$convertvaleur+="SCRIPT/"}} Write-host $convertvaleur } |