Jul 29 2020 05:58 AM
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
Martin
Jul 29 2020 06:59 AM
Jul 29 2020 07:04 AM
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?
Cheers
Martin
Jul 29 2020 07:33 AM - edited Jul 29 2020 07:35 AM
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
$creds.Local1
$creds.Local2
$creds.Local3
# 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
Martin
Jul 29 2020 10:47 AM - edited Jul 29 2020 10:51 AM
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){
$output=@()
$identity=$entry.username.split("@")[0]
$Username = $entry.username
$Password = $entry.password
$SecurePassword = convertto-securestring $Password -asplaintext -force
$credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword
$output=$credentials
$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.
Aug 07 2020 09:31 AM
SolutionThere 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.
Aug 07 2020 09:31 AM
SolutionThere 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.