PowerTip: Using Credentials in PowerShell

PowerTip: Using Credentials in PowerShell

  • Comments 11
  • Likes

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

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • @TSGs

    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

  • 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

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

  • @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.

  • @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.

  • @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.

  • @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.

  • @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.

  • @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.

  • @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

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