A PowerShell module that allows for secure storage and access of credentials to use with scripts, other modules and automation.
It's recommended to install this module persistently so it loads for each PowerShell session automatically.
cd C:\Program Files\WindowsPowerShell\Modules
git clone git@github.com:giffgaff/it-pscreds.git PSCreds
- Restart any open PowerShell windows to use
- Open up your PS terminal
New-Creds -Name ImportantCreds
- Enter the username and password you'd like to save
- A credentials file will be generated in your %APPDATA%\local directory or wherever you specified
In most scenarios you're going to want to save credentials in a folder that the system or all users can access to allow for scheduling and automation.
New-Creds -Name ImportantCreds -Path C:\Creds
- In your script or module create a variable to store the retrieved credentials (i.e.
$Creds = Read-Creds -Name ImportantCreds
) - You can then use the encrypted credentials in the same way you'd use credentials obtained via the Get-Credential function
$Creds = Read-Creds -Name ImportantCreds
$Password = $Creds.GetNetworkCredential().Password
PSCreds uses the native Get-Credential function to prompt for credentials on the command line. These are then encrypted and only usable on the machine they were entered on.
It then uses the Export-CliXml command to create and a file to store the encrypted credentials in, in a location of your choosing.
When it comes to using the creds, a simple Import-CliXml
call is made to re-import the credentials and return them.
In your script or module you can use the credentials in the same way you'd use credentials stored with the Get-Credential command.