I have been trying to come up with a way to get the samaccountname for all users in AD and then their managers samaccountname and export to a saved directory, then send an email out with a notice the scheduled task runs.
I have gotten as far as the script below, and it does give me the samaccountname of the users and manager, but I don't need the displayname, or I should say the people that want this don't want the displayname included.
I then can't figure out a way to send an email that the windows 2012 scheduled task has run. Can anyone help me?
I'd like to email out the scheduled task results as well as the csv file if possible?