Reddit user u/sys_admin00 requested help to create a script to create new Active Directory accounts and output any user accounts not created due to collisions. The output should go to a CSV file.
I build the below code to try to meet all of his requests.
-Create users account from the TEST.csv file
-Output any accounts not created due to collisions, the output file will only need SamAccountName
-Output any errors on screen
Create users account from the TEST.csv file
Output any accounts not created due to collisions, output file will only need SamAccountName
Output any errors on screen
The script will import the TEST.csv file into variable $ADUsers, then run a foreach loop on using $ADUsers. To check if the username is in use, I do a filter for the Username, if the test variable is $NULL then I know its available. If the test variable is not $NULL then write a warning saying the username was found and write Username
Full code:
댓글