none
How to stop "get-credential" cmdlet from throwing this message on powershell window RRS feed

  • Question

  • Dear All,

    Any suggestion on how we can stop "get-credential" cmdlet from throwing following message to powershell window.

    "

    cmdlet Get-Credential at command pipeline position 1
    Supply values for the following parameters:
    Credential

    "

    Thursday, November 19, 2015 2:54 PM

Answers

  • Do you know which account you're going to use? If so, specify it with the -Credential parameter.


    EDIT: You'll also need to pipe through Out-Null if you wish to suppress all output.


    EDIT2: Examples:

    PS C:\> Get-Credential
    
    cmdlet Get-Credential at command pipeline position 1
    Supply values for the following parameters:
    Credential
    
    UserName                                                                                                       Password
    --------                                                                                                       --------
    domain\user                                                                                System.Security.SecureString
    
    
    PS C:\> Get-Credential -Credential domain\user
    
    UserName                                                                                                       Password
    --------                                                                                                       --------
    domain\user                                                                                System.Security.SecureString
    
    
    PS C:\> Get-Credential -Credential domain\user | Out-Null


    • Edited by Mike Laughlin Thursday, November 19, 2015 3:11 PM
    • Marked as answer by Moonshekar Thursday, November 19, 2015 4:29 PM
    Thursday, November 19, 2015 3:06 PM
  • get-credential -credential "enterusername"

    above seems to work the same way as 

    Get-Credential -Credential domain\user | Out-Null

    • Marked as answer by Moonshekar Thursday, November 19, 2015 4:35 PM
    Thursday, November 19, 2015 4:35 PM

All replies

  • Hi Moonshekar,

    the only way you can do this is by not using the Get-Credential cmdlet at all.

    You can manually create PSCredential Objects using the New-Object cmdlet.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Thursday, November 19, 2015 3:03 PM
  • What did you do to cause that to happen?


    \_(ツ)_/

    Thursday, November 19, 2015 3:03 PM
  • What did you do to cause that to happen?


    \_(ツ)_/

    Simply run Get-Credential in the console, with no parameters

    There's no place like 127.0.0.1

    Thursday, November 19, 2015 3:04 PM
  • Do you know which account you're going to use? If so, specify it with the -Credential parameter.


    EDIT: You'll also need to pipe through Out-Null if you wish to suppress all output.


    EDIT2: Examples:

    PS C:\> Get-Credential
    
    cmdlet Get-Credential at command pipeline position 1
    Supply values for the following parameters:
    Credential
    
    UserName                                                                                                       Password
    --------                                                                                                       --------
    domain\user                                                                                System.Security.SecureString
    
    
    PS C:\> Get-Credential -Credential domain\user
    
    UserName                                                                                                       Password
    --------                                                                                                       --------
    domain\user                                                                                System.Security.SecureString
    
    
    PS C:\> Get-Credential -Credential domain\user | Out-Null


    • Edited by Mike Laughlin Thursday, November 19, 2015 3:11 PM
    • Marked as answer by Moonshekar Thursday, November 19, 2015 4:29 PM
    Thursday, November 19, 2015 3:06 PM
  • You have to put in values in the dialog.  If you cancel or hit enter or escape with no values it will throw and exception.


    \_(ツ)_/

    Thursday, November 19, 2015 3:08 PM
  • get-credential -credential "enterusername"

    above seems to work the same way as 

    Get-Credential -Credential domain\user | Out-Null

    • Marked as answer by Moonshekar Thursday, November 19, 2015 4:35 PM
    Thursday, November 19, 2015 4:35 PM
  • Get-Credential -Credential "$env:USERDOMAIN\$env:USERNAME"

    this puts the current user's information in automatically



    • Edited by sbogar Friday, February 17, 2017 7:50 PM
    Friday, February 17, 2017 7:48 PM