@GuestGuivenchi Thank you for reaching out to us, As I understand you are looking for PowerShell script to fetch these details Manager & Company Name for the users defined in Azure AD.
Try the below script to achieve the desired outcome, tested the same and it works as expected.
$userlist= Get-AzureADUser -All $true
$output = @()
foreach( $item in $userlist){
$mgname=Get-AzureADUserManager -ObjectId $item.ObjectId
$output += [pscustomobject]@{
"Display Name" = $item.DisplayName
"Company Name" = $item.companyName
"Manager Name" = $mgname.DisplayName
}
}
$output | Export-Csv C:\Test\sampleuser_2.csv
Let me know if you have any further questions, feel free to post back.
Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.