powershell script not working as expected
I am trying to achieve below format output with my PowerShell script. Expected Output:
"TestParam": {
"5903-95856-24869-e43": {
"CallerName": "testparner",
"ClientId": "123-45-789",
"ClientSecret": {
"KeyVaultSecretName": "ClientSecret"
}
}
}
Script I am using
$PartnerName="testparner"
$ClientID="123-45-789"
$DM=@{
"5903-95856-24869-e43"=@{
"CallerName"= $PartnerName
"ClientId"= $ClientID
"ClientSecret"= @{
"KeyVaultSecretName"= "ClientSecret"
}
}
}
$jsonData = @{
"TestParam"= $DM
}
$jsonString = $jsonData | ConvertTo-Json
$jsonString
Actual output I am getting using above script:
Please try the following code; it is expected to address the problem you're facing.
$PartnerName="testparner"
$ClientID="123-45-789"
$DM=@{
"5903-95856-24869-e43"=@{
"CallerName"= $PartnerName
"ClientId"= $ClientID
"ClientSecret"= @{
"KeyVaultSecretName"= "ClientSecret"
}
}
}
$jsonData = @{
"TestParam"= $DM
}
$jsonString = $jsonData | ConvertTo-Json -Depth 4
$jsonString