I have the script where I am trying to put my AWS credentials in a remote server using powershell script.
Issue I am facing : Leading zeros of the AWS AccountID (one of the powershell script argument) is not getting retained. I am new to PS script. Need guidance on retaining the zeros of the accountID.
Example -- AccountID -- 000009876543 - Here leading zeros are not getting retained and an entry without zeros gets created in the server. However, 900000876543 is handed successfully.
Script -
$user = $args[7] #userid
$pass = $args[8] #password
$pair = "$($user):$($pass)" #pair
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }
$c1=$args[0]
$path=$args[1]
$cert=$args[2]
$p1=$args[3]
$awsacct=$args[4] #account_id
$awsak=$args[5] #access_key
$awssk=$args[6] #secret_key
$body9="{`"project`": { `"href`": `"/tenants/$c1/projects/$p1`"},`"account`": {`"href`": `"/tenants/$c1/accounts/$awsacct`"},`"credential`":{ `"type`": `"key`",`"accessKey`": `""+$awsak+"`", `"secretKey`": `""+$awssk+"`"}}"
$r=Invoke-WebRequest -uri "$path/tenants/$c1/credentials/$awsak" -Headers $headers -Certificate $cert -ContentType application/json -Method PUT -Body $body9
$r.Content