Credential Management Module

Manage credentials saved to the windows credential manager and call them as clear text or a PSCredential object to be used by other PowerShell Commends









Install


from a PowerShell console window run

Install-Module -Name CredentialManagement

or you can download the module package form here


Extract the package using 7zip or change the file extension to .zip 


Commands 

Add-StoredCredentials

Add credentials to the Windows Credential Manager

Syntax

Add-StoredCredentials [[-UserName][string]] [[-Password][string]] [[-Target][string]] [[-Type][string]] [[-Comment][string]]

Parameters

  • -UserName 
    • Type: String
    • Required: Yes 
    • user name of the credential that is to be stored 
  • -Password 
    • Type: string
    • Required: No
    • Password that is to be stored 
    • If no password is specified a secure message box will display asking for the password 
  • -Target
    • Type: string
    • Required: No
    • Default: Value  of -UserName
    • Used to identify what the credentials are to be used for 
  • -Comment 
    • Type: string
    • Required: No
    • Default: Date the credentials created and what user created them
    • Adds a comment to the credentials in the credential store

Examples

Stores the user name and password as a generic entry for https://my.account.com

Add-StoredCreentials -UserName SamDoe -Password $Password1! -Target https://my.account.com

Remove-StoredCredentials

Remove stored credentials from the Windows Credential Manager

Syntax

Get-StoredCredentials [[-Target][string]]  [[-Type][string]]

Parameters

  • -Target
    • Type: string
    • Required: Yes
    • Used to identify what the credentials are to be removed
  • -Type
    • Type: string
    • Required: No
    • Default: GENERIC
    • Used to identify what the credentials are to be removed

Examples

Removes the stored credentials for https://my.account.com

Remove-StoredCredentials -Target https://my.account.com

Get-StoredCredentials

Gets the specified credentials stored in Credential Manager as a PSCredential object.

Syntax

Get-StoredCredentials [[-Target][string]] [[-Type][string]]  

Parameters

  • -Target
    • Type: string
    • Required: Yes
    • Used to identify what credentials to get
  • -Type
    • Type: string
    • Required: No
    • Default: GENERIC
    • Used to identify what credentials to get

Examples

Gets the credentials for https://my.account.com and stores them in the $Creds variable

$Creds = Get-StoredCredentials -Target https://my.account.com

The credenatials can then be used in a command the accepts a PSCredential object like
New-PSSession -ComputerName MyComputer -Credential $Creds

Get-ClearTextStoredCredentials

Gets the specified credentials stored in Credential Manager

Syntax

Get-ClearTextStoredCredentials [[-Target][string]] [[-Type][string]]  

Parameters

  • -Target
    • Type: string
    • Required: Yes
    • Used to identify what credentials to get
  • -Type
    • Type: string
    • Required: No
    • Default: GENERIC
    • Used to identify what credentials to get

Examples

Gets the credentials for https://my.account.com and stores them in the $Creds variable


$Creds = Get-ClearTextStoredCredentials -Target https://my.account.com

The credentials can then be used in commands the do not accept PSCredential object like
Register-ScheduledTask -User $creds.UserName -Password $Creds.Password



Comments