Hi All
the goal of this to retrieve the objectID from a disabled user and to remove this user from all the azureAD groups.
In order to do this I need to get the object from the user first
when using this as a standalone command
get-AzureAdUser -SearchString "SamaccountName" |select objectId, Displayname, UserPrincipalName |export-csv c:\temp\AzureAdUsers.csv -notypeinformation -append
it works like a charm
however when I want to use it in a foreach I get the below mentioned error
$users = import-csv C:\users\Public\Documents\CSV\ToRemove.csv foreach($user in $users){ get-azureAdUser -SearchString "$user.SamAccountName" |select Objectid,displayname,UserPrincipalName |export-csv c:\temp\azureADusers.csv -NoTypeInformation -append }
and the error is this
get-azureAdUser : Error occurred while executing GetUsers
Code: Request_UnsupportedQuery
Message: Unsupported or invalid query filter clause specified for property ‘userPrincipalName’ of resource ‘User’.
any Idea on how to get this sorted out?