SOLVED

Azure Cloud Shell error with string

Copper Contributor

I get this error:

Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'ObjectId'. Specified method is not | supported.'

 

Trying to pass this variable to Get-AzureADDirectoryRoleMember , I think I'm missing how to add "" somewhere in "-ObjectId $admins.ObjectId"?

code:

$admins = Get-AzureADDirectoryRole | where{$_.displayname -like "*administrator"}
Get-AzureADDirectoryRoleMember -ObjectId $admins.ObjectId

 

 

3 Replies
best response confirmed by EdSchreibman (Copper Contributor)
Solution
Well there are multiple built-in roles that match your query, so the $admins variable is effectively an array, meaning that $admins.ObjectId is not a string either. This will work:

Get-AzureADDirectoryRoleMember -ObjectId $admins[0].ObjectId

and repeat for each group.
Perfect. Thanks

@VasilMichevIt sloved my issue, thanks for posting solution 

1 best response

Accepted Solutions
best response confirmed by EdSchreibman (Copper Contributor)
Solution
Well there are multiple built-in roles that match your query, so the $admins variable is effectively an array, meaning that $admins.ObjectId is not a string either. This will work:

Get-AzureADDirectoryRoleMember -ObjectId $admins[0].ObjectId

and repeat for each group.

View solution in original post