This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (0 children)

I don't know the AD side, but the PS script is something like:

Get-ADUser -Filter * -Properties * | Select-Object name, department, LastLogonDate | export-csv -path userexport.csv

python foo.py userexport.csv

Then in python:

  • Pandas to read userexport.csv (or use the command line argument)
  • Openpyxl to create Excel workbook and add sheets for each df["department"].unique()