Thanks Durga for your response, followed the above steps after getting the KeyVaultSecret was getting the values as ***. After encoding and decoding the secret and passing the decoded values worked.
Had Question, how to retreive all the secrets from the KeyVault and pass it through the encoding and decoding in loop.
After the below command , was getting the output as below, how to fetch all the values of secret after the | ( which is ***), currently there are 3 secrets and how to pass it to $encodedSecret and $decodedvalue in foreach loop.
For-each *** value --> to Encode and Decode it.
$keyVaultValue = Get-AzKeyVaultSecret -VaultName "xxxx"
$keyVaultValue | % {Write-Output "$($.name) | $(Get-AzKeyVaultSecret -VaultName $.VaultName -Name $_.Name -AsPlainText)"}
Write-Host "Value of keyVaultValueSecret ": $keyVaultValueSecret
Value of keyVaultValueSecret :
DBUser | ***
DBPass | ***
DBPort | ***
#EncodedSecret
$encodedSecret = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($keyVaultValue))
#$encodedSecret = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($secret))
Write-Host "Value of encodedSecret" $encodedSecret
#DecodedSecret
$decodedvalue = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encodedSecret))
Write-Host "Value of DecodedSecret" $decodedvalue