PSCredential
is a PowerShell module that provides functions for managing credentials.
It allows users to create, save, and restore PSCredential
objects from disk.
This module requires:
- The PSModule framework for building, testing, and publishing the module.
To install the module from the PowerShell Gallery, you can use the following command:
Install-PSResource -Name PSCredential
Import-Module -Name PSCredential
Here are some typical use cases for the module.
This function generates a PSCredential
object using user input.
New-PSCredential
This prompts the user for a username and password and returns a PSCredential
object.
Alternatively, you can specify the credentials explicitly:
New-PSCredential -Username 'admin' -Password (ConvertTo-SecureString 'P@ssw0rd!' -AsPlainText -Force)
You can save a credential to a file using Save-PSCredential
:
$credential = Get-Credential
Save-PSCredential -Credential $credential -Path 'C:\secure\credential.cred'
This saves the credential to C:\secure\credential.cred
.
To restore a credential object from a previously saved file:
Restore-PSCredential -Path 'C:\secure\credential.cred'
Alternatively, you can use pipeline input:
'C:\secure\credential.cred' | Restore-PSCredential
To find more examples of how to use the module, please refer to the examples folder.
Alternatively, you can use the following commands:
-
Find available commands in the module:
Get-Command -Module PSCredential
-
Get examples for a specific command:
Get-Help -Examples New-PSCredential
For further documentation, please refer to:
Whether you're a coder or not, you can contribute to this project!
If you experience unexpected behavior, errors, or missing functionality, you can help by submitting bug reports and feature requests. Please visit the issues tab and submit a new issue.
If you are a developer, we welcome your contributions! Please read the Contribution Guidelines for more information. You can either help by picking up an existing issue or submit a new one if you have an idea for a feature or improvement.
The Export-Clixml cmdlet is used to save credentials to disk, is not secure on Linux and macOS, and should be used with caution. For more information read the Export-Clixml documentation.