Skip to content

New-PSUAuthenticationResult

SYNOPSIS

Returns an authentication result for forms authentication.

SYNTAX

New-PSUAuthenticationResult [-Claims <ScriptBlock>] [-Success] [-UserName <String>] [-ErrorMessage <String>]
 [<CommonParameters>]

DESCRIPTION

Returns an authentication result for forms authentication. This allows you to return the user name, whether the authentication was successful, custom claims and an error message when the user attempts to login.

EXAMPLES

Example 1

param($Credential)

if ($Credential.UserName -eq 'Adam')
{
    New-PSUAuthenticationResult -UserName 'Adam' -Success
}
else 
{
    New-PSUAuthenticationResult -ErrorMessage "Hey! You aren't Adam"
}

Returns a successful authentication result if the user name is 'Adam'. Returns a custom error message if that user is not.

PARAMETERS

-Claims

The claims to return from this authentication result. Claims typically are features of the current user account like the Active Directory group membership. Use the new-PSUAuthorizationClaim cmdlet to define these claims.

Type: System.Management.Automation.ScriptBlock
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ErrorMessage

The custom error message to return upon unsuccessful logins.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Success

A switch parameter that signals that this authentication attempt was successful.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

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

-UserName

The user name to set on the identity of the user logging in.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
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

None

OUTPUTS

System.Object

NOTES

New-PSUAuthorizationClaim

Set-PSUAuthenticationMethod

Back to top