I'm trying to synchronize employee job descriptions, department information, and managers between Outlook and Hibob, but ADUC and Hibob don't integrate well. Since checking each employee manually would take forever, I thought generating a CSV file with employee data would help. I've got a CSV from HR, but now I need one from Active Directory to compare. I've done some research and found that PowerShell might be the solution, but I'm struggling to execute it properly. My latest attempt included trying to use the Microsoft Graph module, but I ran into errors about not recognizing the 'Connect-MgGraph' command and issues with importing the module. Any tips on how to export user data, especially the manager field, from Active Directory?
2 Answers
You can also manipulate the output to include managers' names directly in the export. Use this for the manager field:
```powershell
Get-ADUser -Filter * -Properties Manager | Select-Object Name,@{Name='Manager';Expression={(Get-ADUser $_.Manager -Properties DisplayName).DisplayName}}
```
Ensure you have the correct permissions and that the AD module is loaded properly.
It sounds like you're using the wrong module for your Active Directory setup. If it's on-prem, you should stick with the Active Directory module. Here’s a simple script you could start with:
```powershell
Import-Module ActiveDirectory
$Properties = @( "SamAccountName", "DisplayName", "Mail", "Department", "Title", "Manager" )
Get-ADUser -Filter { Enabled -eq $True } -Properties $Properties | Select-Object -Property $Properties | Export-Csv -NoTypeInformation -Encoding ASCII -Path "all_users.csv"
```
Just adjust the `$Properties` array to include the attributes you need! This should help you export the data you require.
Make sure to filter the users properly, especially if your AD has a lot of accounts. You might want to tailor it down further than just 'all enabled accounts' to speed things up.

This is a good approach, but remember that if managers have the same names, it's better to use unique identifiers for the HR system.