SOLVED

Azure Cloud Shell error with string

New 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

 

 

2 Replies
best response confirmed by EdSchreibman (New 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