New day, new PowerShell Magic….
One of the customer manger has contacted us with the below requirement:
- Export particular attributes for Direct reports from multiple managers.
- Input will be provided via samacountnames of managers thru text file.
Manager,FirstName, LastName, EmailAddress,Department, Location, Employeeid
We have used PowerShell Active Directory Module to achieve this as it has DirectReports attribute that we can loop thru.
Line 160 of Script:
$directrports = Get-ADUser -id $user -Properties directreports | Select -ExpandProperty directreports
Download/Install the script from PowerShell Gallery or from technet script gallery.
Once installed, you will be able to find the script in below location , you can run from there or copy it to some other location.
Now when you run it, it will prompt you for the input text file which contains managers samaccountnames.
text file contents:
It will also create report and logs folder, report will be generated in CSV form and will be saved in report folder.
You can modify the script , add other attributes as per your requirement by updating the code between line 162 to 171.
I will upload the solution to Technet Script Gallery as well in coming week, as of now gallery is not opening correctly in browser and upload is not working.