Find file
Fetching contributors…
Cannot retrieve contributors at this time
102 lines (66 sloc) 2.54 KB


What this for?

This module allows you to handle your credential with Windows Credential Manager.

It used to be requires P/Invoke to handle Windows Credential Manager. > PInvoke.Net

However there are PasswordVault class for Windows 8 StoreApops in .NET framework and it allows not only StoreApps but also PowerShell to manage their Credential super easy.


Set Credential

Below sample code will save your Credential as hoge.

Set-WindowsCredential -ResourceName hoge -Credential (Get-Credential)

Get Credential

Get-WindowsCredential -ResourceName hoge

This retrieve all user credential for ResourceName 'hoge'.

UserName                                                                             Password
--------                                                                             --------
hoge                                                             System.Security.SecureString

You can specify username for the Resource.

Get-WindowsCredential -ResourceName hoge -UserName hoge

Want to retrieve all credentials? Use -All switch.

Get-WindowsCredential -All

Test Credential is exist

You can test if credential is exist or not.

Test-WindowsCredential -ResourceName hoge

If credential is exist then true will be return. If not false will return.

You can specify Resource and UserName.

Test-WindowsCredential -ResourceName hoge -UserName hoge

Remove Credential

You can remove credential.

Remove-WindowsCredential -ResourceName hoge -UserName hoge

If you want to remove all credential in ResourceName, then use -All switch.

Remove-WindowsCredential -ResourceName hoge -All


As PasswordVault use Windows.Security.Credentials.PasswordCredential, this module convert to/from PSCredential.


Convert PSCredential TO Windows.Security.Credentials.PasswordCredential.

ConvertTo-PasswordCredential -Credential (Get-Credential) -ResourceName hoge


Convert Windows.Security.Credentials.PasswordCredential to PSCredential.

ConvertFrom-PasswordCredential -Credential $Credential