Need help with Get-Credential

Welcome Forums General PowerShell Q&A Need help with Get-Credential

This topic contains 2 replies, has 2 voices, and was last updated by

2 months, 1 week ago.

  • Author
  • #133824

    Points: -6
    Rank: Member

    Hi there


    I'm trying to use this syntax:

    $cred = Get-Credential -Credential $env:UserName


    This works, but when I use the cancel-button I get the follwing error:

    Get-Credential : Impossible de lier l'argument au paramètre « Credential », car il a la valeur Null.
    Au caractère C:\Users\xxxxxx\Documents\Dimo\PS1\AD\Check_User_Password.PS1:2 : 36
    + $cred = Get-Credential -Credential $env:UserName -ErrorAction Silentl ...
    + ~~~~~~~~~~~~~
    + CategoryInfo : InvalidData : (:) [Get-Credential], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetCredenti

    Using -ErrorAction SilentlyContinue doesn't change anything.


    Thanks in adanace for your help.


    Best regards




  • #133838

    Points: 1,165
    Helping Hand
    Rank: Community Hero

    You might use a try catch block.

  • #133850

    Points: -6
    Rank: Member

    Thanks Olaf

    It works now


    Best regards

You must be logged in to reply to this topic.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort