PowerTip: Using Credentials in PowerShell

Summary: Learn how to find Windows PowerShell cmdlets and providers that support credentials.

Hey, Scripting Guy! Question How can I find which Windows PowerShell cmdlets support the credential parameter?

Hey, Scripting Guy! Answer Use the Get-Command cmdlet with a command such as:

Get-Command -ParameterName credential

Hey, Scripting Guy! Question How can I find which Windows PowerShell providers support credentials?

Hey, Scripting Guy! Answer Use the Get-PSProvider cmdlet and pipe the results to Where-Object. Then look for credential in the capabilities property. An example for doing this in Windows PowerShell 3.0 is shown here.

Get-PSProvider | where -Property capabilities -Value credential -Match

Comments (11)

  1. Get-PSProvider | where -Property capabilities -Value credential -Match

    Ed, that is probably the worst example of simplified where syntax. 😉

    The following is really easier to read (and type):

    Get-PSProvider | where capabilities -match credential

  2. jrv says:

    @Ed – unfortuantely I fo not have any hardware that will work that I can repurpose right now,  Evert macine I have cause WIndwos 8 to complain about memory, graphic card or other issue.   The ones (2) thaat would work I cannot alter at this time.

  3. jrv says:

    @Ed – and who have harware that will run this.  I cannot run WIn8 form many things until I get my clients to upgrade.  I need a dedicated patform.  Other will have similar issues.

    In fact PosH 3 is released but it is a limited release.  I want ti for Win7 and WS2008R2.  That i sthe release I am looking ofr and I believe most here are too.

  4. jrv says:

    @Ed – I know and I like it.  I am trying to do that but I do not a have enough hardware outside of my cilents environment to set that up.  I am working on a new project where I will be able to afford more hardware.

  5. jrv says:


    Since your answers are using PowerShell 3.0 only are we to assum that 3.0 will be released in the next few days?

    Get-Command -ParameterName credential

    This only works in 3.0

  6. @Ed

    The point of my comment is that posted command is hard to read. I'm all for using full parameter names (especially when we explain something to new users), but with this new Where-Object syntax, full parameter names don't work so well. And putting -match switch parameter at the end didn't help either. IMO, this might work better:

    where -Property capabilities -match -Value credential

  7. Ed Wilson says:

    @JRV PowerShell 3 is in Windows 8, and is therefore already available to those with TechNet and MSDN subscriptions.

  8. Ed Wilson says:

    @Aleksandar Nikolić  As you point out, you can leave out positional parameters. I left the parameters in my "worst example" so that people would realize what the command is actually doing. For example, without the parameter names, you may suppose, but you do not know exactly what a command is doing. After, you know what the command is doing, and you know what you are doing, then by all means, leave the parameters out, use aliases, or create aliases to make the syntax bearable.

  9. Ed Wilson says:

    @JRV from a hardware perspective? I am running Windows 8 on a four year old laptop, and it runs very well … I cannot get the HyperV part to work (on the old laptop) but everything else runs even better than Windows 7 does.

  10. Ed Wilson says:

    @JRV have you tried running Windows 8 in a virtual environment? Windows 8 runs really in hyperv. I generally set my memory range initial at 256 mb and allow it to grow to 512 mb, and it works really well.

  11. ed wilson says:

    @Aleksandar Nikolić  You are right. Moving the switch up does make the command clearer to read. Thanks for sharing this.

Skip to main content