Skip to content

Get-OneUser

SYNOPSIS

Retrieves a single Active Directory user based on input criteria.

SYNTAX

Get-OneUser [[-User] <String>] [[-Prompt] <String>] [[-ldapfilter] <String>] [-Reprompt] [<CommonParameters>]

DESCRIPTION

The `Get-OneUser` function searches Active Directory for a specified user. If no or multiple matches are found, the user is prompted to refine their input or select the correct user. If the user cancels the operation, the function returns `$null`.

EXAMPLES

EXAMPLE 1

Get-OneUser

Prompts the user to input a name and searches for a unique user in Active Directory.

EXAMPLE 2

Get-OneUser -Prompt "Enter mailbox name" -LDAPFilter "(&(homeMDB=*)(objectClass=User))"

Prompts the user to input a mailbox name and searches Active Directory for mailbox users only.

EXAMPLE 3

Get-OneUser "janssens"

Searches for users with "janssens" in their name and: - Returns the DN if exactly one match is found. - Prompts the user to refine their input if no or multiple matches are found.

PARAMETERS

-User

A partial or full name, email address, or other identifier for the user.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-Prompt

A custom prompt message displayed when the user is asked to input a name.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: Geef een gebruiker
Accept pipeline input: False
Accept wildcard characters: False

-ldapfilter

An optional LDAP filter that all users must match.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: (sAMAccountName=*)
Accept pipeline input: False
Accept wildcard characters: False

-Reprompt

A switch parameter that, when specified, prompts the user again if the provided input does not match any user.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES