Azure devops: value cannot be null parameter token azure powershell

I am running an Azure Powershell task in Azure DevOps.

Inside the script I use the following command

 Get-AzureRmADUser -UserPrincipalName $adusernameNewPermission 

But my Release pipeline fails with following error code

 ##[error]Value cannot be null. Parameter name: token 

First I thought that the command didn’t have the right context or enough permission so I’ve added the defaultprofile.

 Get-AzureRmADUser -DefaultProfile (Get-AzureRmContext) -UserPrincipalName $adusernameNewPermission 

The GetAzureRmContext did go to the right context if I print the output of that command.

The command itself didn’t had any problem when running locally (with my own user account) So the only reason I think its heading is that the service connection doesn’t have the right to perform that action. But my user account has the least permissions on the tenant whilst the service connnection in azure devops has much more permissions.

It’s driving me crazy where the problem lays with this one. Which token does it mean ? No reasonable error message 🙁

Does someone encounter the same problem or knows what I am missing ?

PS: the $adusernameNewPermission variable works like I said the exact same code runs perfectly on my local machine with the only difference being the user that is logged in.

submitted by /u/bachahbar
[link] [comments]

Leave a Reply