I am modifying a script I made awhile back and wanted to get some guidance.
Currently, the script just grabs a list of all the groups a user is a member of and exports them to a .csv file. However, I am also trying to get the user’s manager’s email onto that spreadsheet so I can email them the list. I can get it to grab the Manager from AD, but I am struggling a bit of how I can get their email onto the spreadsheet.
Here is my script at the moment
Get-AzureADUser -SearchString $user | Get-AzureADUserManager | Get-AzureADUserMembership | % {Get-AzureADObjectByObjectId -ObjectId $_.ObjectId | select DisplayName,Description} | Export-csv -Path C:tempGroupList.csv
'Manager Email'
Write-Output $manager