I working on a script to configure aws end points in a backup tool. I am not seeing why the data is getting treated differently.
Here is the script:
#Add AWS Account
$key="key"
$skey="skey"
$region="eu-west-1, us-east-1"
$region = $region.Replace(' ','')
$region = $region.Replace(',','","')
$region="`"$region`""
$region
$awsadd = @{
accesskey="$key"
secretkey="$skey"
#regions=@("eu-west-1", "us-east-1")
regions=@($region)
}
$json = $awsadd |ConvertTo-Json
$json
These two get treated different and i am not sure why:
#regions=@("eu-west-1", "us-east-1")
regions=@($region)
When i have the text typed out it works right:
$json = $awsadd |ConvertTo-Json
$json
{
"regions": [
"eu-west-1",
"us-east-1"
],
When i use the var it looks like this:
{
"regions": [
"\"eu-west-1\",\"us-east-1\""
],
The second way does not work. Thoughts on how i can do this?