It works using the URL because you are specifically asking for it. If you leave off the $select=country
or /Country
then you don't get it. That is what Get-MgUser
is calling. However that cmdlet let's you specify additional properties to retrieve via the -Property
argument. So ask for the country as well. Perhaps something like this:
Get-MgUser -UserId $SameUserId -Property Country