Secure Way to store lots of credentials using powershell

Occasional Contributor

Dear Community 

I wanted to ask if there is any way I can store lots of creedentials while still being able to use them in Powershell?


I dont want to enter anything in a popup window, because there are way to many credentials to to that by hand.

Is it possible that I can just put them in some kind of file and then get the wanted informations (while the file or its contents are somehow encrypted)?


Thanks in advance




5 Replies
i use below to export creds into an xml file (username is in plain text and passwords gets encrypted ) :-
Get-Credential | Export-Clixml -Path "C:\Users\username\Desktop\Cred.xml"
and then call them later using below in the required cmdlet:-
"-Credential (Import-Clixml "C:\Users\username\Desktop\Cred.xml")"


First of all, thank you for your answer!

I like your way of exporting it into a .xml file. :)

But the thing is that I have to enter the credentials into a popup window. I have too many Credentials to be even remotely able to do it this way...

Is it somehow possible that I could put all of the credentials into a .csv (for example) with the username as plain text and the password encrypted using SecureString so I have all them in one file?





Well I kind of found a solution:



#set credentials
#set credentials path
$CredPath = "C:\Scripts\Certify\mycreds.xml"
#How many Credential Windows are going to show
$creds = @{
  Local1 = Get-Credential -Message LocalAccount1
  Local2 = Get-Credential -Message LocalAccount2
  Local3 = Get-Credential -Message LocalAccount3
#export credentials which have been typed in manually as xml
$creds | Export-Clixml -Path $CredPath

#get credentials
#import credentials
$creds = Import-Clixml -Path $CredPath 

#list credentials

# example
Get-WmiObject -Class Win32_BIOS -ComputerName server01 -Credential $creds.Local1



My only problem now: there are still annoying popup windows where I have to enter all of this after one another


Can anyone help me with that?


Thanks in advance



you can create an xml file for each set of credentials by first storing the creds in plain text in a csv file, using below :-
$file = Import-Csv "C:\temp\file.csv"
foreach($entry in $file){
$Username = $entry.username
$Password = $entry.password
$SecurePassword = convertto-securestring $Password -asplaintext -force
$credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword
$output | Export-Clixml -Path "C:\temp\$identity.xml"
You can create a single xml file as well for all creds however i don't know if there will be an easy way to use that file to feed credentials back into a PS session.

best response confirmed by __Martin__ (Occasional Contributor)


There are many ways to encrypt your password and store them in text file, csv, database, Windows credential vault and etc., In the end you still need to decrypt it to be able to use it.


So, my best bet would be to use Azure Key Vault.