Forum Discussion
Get information from parameter store in JSON or in different lines
Hi everyone!
I need some help. I have some user and password credentials in a parameter store. I need to retrieve this information to pass a credential to join a server in a domain. This retrieve can be to Json too.
At this moment Im using each value per line.
Example:
myuser
myuserpassword
and using this to retrieve this values:
$username = (Get-SSMParameterValue -Name joinadwin -WithDecryption $True).Parameters[0].Value
$password = (Get-SSMParameterValue -Name joinadwin -WithDecryption $True).Parameters[1].Value
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
In the step of a credential I receive this error:
New-Object : Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument "password" is null. Change the value of argument "password" to a non-null value."
Using the Write-Host $password i saw the myuserpassword value
Hey, Rubens.
I'm not quite sure what you mean by filter, but here's some quick illustrations on how to work with your JSON string.
Cheers,
Lain
- rubensfontesCopper ContributorMy username and password had a \ and I got escape error. I put one more \ on each one and it worked.
Thank you everyone! - You need to convert it to a secure string, $credential=New-Object System.Management.Automation.PSCredential -Argumentlist @($Username,(ConvertTo-SecureString -String $Password -AsPlainText -Force))
- LainRobertsonSilver Contributor
Something is off with this scenario, as using a plain-text string throws a different error to the "null" error mentioned in the question.
My confusion is increased by the $password variable apparently showing the plain-text string value obtained from the AWS commandlet.
Mind you, my mock test was in Windows PowerShell 5.1, so perhaps what you've suggested is right for PowerShell - I'm not sure. Either way, I'm at a loss.
Here's an illustration of the difference between $null and plain-text strings and their corresponding errors under Windows PowerShell 5.1.
Cheers,
Lain
- I got this from there, didn't test it but usually you need to convertto-securestring for these kind of things.. https://social.technet.microsoft.com/Forums/en-US/ebfc706d-93be-4ca0-83e0-33d9e072fb97/powershell-script-monitor-with-encrypted-password?forum=operationsmanagerauthoring
- rubensfontesCopper ContributorI can't filter values in Json...
{
"username": "domain\teste",
"password": "passsss"
}- LainRobertsonSilver Contributor
Hey, Rubens.
I'm not quite sure what you mean by filter, but here's some quick illustrations on how to work with your JSON string.
Cheers,
Lain