As part of Azure devops pipeline , I need hit the API to get the Oauth token and use it in the subsequent steps, I was able to achieve this, the only problem is the Oauth is displayed in the devops console, which I want to suppress it, is there a way I can suppress the output or pipe the Invoke-RestMethod to variable? I tried the | Out-Null but this also did not store the response in the variable.
Thanks in advance. cheers.
$response = Invoke-RestMethod 'https://login.microsoftonline.com/xyz/oauth2/v2.0/token' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
$token=$response.access_token