Test-Identity

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

Syntax

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

Description

Attempts to convert an identity name into a System.Security.Principal.SecurityIdentifer object. If the conversion succeeds, the name belongs to a valid local or domain user/group. If conversion fails, the user/group doesn't exist. You can also optionally return the applicable SecurityIdentifier object.

If the identity testing is in another domain, and there is no trust relationship between the current domain the identity's domain, $false will be returned even though the account could exist.

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String The name of the identity to test. true false
PassThru SwitchParameter Returns a System.Security.Principal.SecurityIdentifier 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.