PowerShell to Maintain a Line Managers Group

22 Mar

A simple bit of PowerShell (feel free to optimise it!) to scan AD for all users (that are enabled and have an email address set) and then assuming a group exists called “Line Managers” it will add anyone who has any direct reports into this group, and remove anyone that doesn’t.