Reputation: 35
How to retrieve details which contains information of login user including domain for example let say domain\useralias
from Azure AD for a user input? Note that domain names are there in onprem ad which were sync to Azure AD.
Upvotes: 1
Views: 1318
Reputation: 2447
You can use the OnPremiseDistinguishedName extension property.
Example:-
foreach($line in Get-Content c:\users\myuser\users.txt) {
if($line -match $regex){
$onPremisesDistinguishedName = (Get-AzureADUserExtension -ObjectId $line).get_item("onPremisesDistinguishedName")
$domain = $onPremisesDistinguishedName.split(",")
$alias = $line.Split("@")
$sAMAccountName = ($domain[2]).Substring(3)
$sAMAccountName + "\" + $alias[0]
}
}
Upvotes: 1