> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/da/powershell-kommandoer/new-psuauthenticationresult.md).

# New-PSUAuthenticationResult

New-PSUAuthenticationResult opbygger resultatet af et forsøg på formulargodkendelse i PowerShell Universal, herunder brugernavn og claims.

## Synopsis

Returnerer et godkendelsesresultat til formulargodkendelse.

## Syntaks

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

## Beskrivelse

Returnerer et godkendelsesresultat til formulargodkendelse. Det giver Dem mulighed for at returnere brugernavnet, om godkendelsen lykkedes, brugerdefinerede claims og en fejlmeddelelse, når brugeren forsøger at logge på.

## Eksempler

### Eksempel 1

```powershell
param($Credential)

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

Returnerer et vellykket godkendelsesresultat, hvis brugernavnet er 'Adam'. Returnerer en brugerdefineret fejlmeddelelse, hvis den bruger ikke er det.

## Parametre

### -Claims

Claims, der skal returneres fra dette godkendelsesresultat. Claims er typisk funktioner ved den aktuelle brugerkonto, f.eks. medlemskab af en Active Directory-gruppe. Brug cmdletten new-PSUAuthorizationClaim til at definere disse claims.

```yaml
Type: ScriptBlock
Parameter Sets: (All)
Aliases:

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

### -ErrorMessage

Den brugerdefinerede fejlmeddelelse, der skal returneres ved mislykkede logon.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

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

### -Success

En switch-parameter, der angiver, at dette godkendelsesforsøg lykkedes.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

### -UserName

Brugernavnet, der skal angives på identiteten for den bruger, der logger på.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

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

### CommonParameters

Denne cmdlet understøtter de fælles parametre: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable og -ProgressAction. Se [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216) for at få flere oplysninger.

## Input

### Ingen

## Output

### System.Object

## Noter

## Relaterede links

[New-PSUAuthorizationClaim](/powershell-universal/da/powershell-kommandoer/new-psuauthorizationclaim.md) [Set-PSUAuthenticationMethod](/powershell-universal/da/powershell-kommandoer/set-psuauthenticationmethod.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/da/powershell-kommandoer/new-psuauthenticationresult.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
