Test-Identity

Tests that a name is a valid Windows local or domain user/group.

Syntax

Test-Identity [-Name] <String> [-PassThru] [<CommonParameters>]

Description

Uses the Windows LookupAccountName function to find an identity. If it can't be found, returns $false. Otherwise, it returns $true.

Use the PassThru switch to return a Carbon.Identity object (instead of $true if the identity exists.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The name of the identity to test.

true false
PassThru SwitchParameter

Returns a Carbon.Identity object if the identity exists.

false false False

EXAMPLE 1

Test-Identity -Name 'Administrators

Tests that a user or group called Administrators exists on the local computer.

EXAMPLE 2

Test-Identity -Name 'CARBON\Testers'

Tests that a group called Testers exists in the CARBON domain.

EXAMPLE 3

Test-Identity -Name 'Tester' -PassThru

Tests that a user or group named Tester exists and returns a System.Security.Principal.SecurityIdentifier object if it does.