Bulk import of new users via PowerShell

Overall, the tutorial works great. I noticed when the script is ran, and if the user already exists the following displays. It would think if an account already exists, it would echo something similar to "The specified account $Username already exists. Can you assist make the adjustment?

Hi @erikm

Try adding the following inside the ForEach loop:

> # Check if the user already exists
>     $UserExists = Get-ADUser -Filter "UserPrincipalName -eq '$Username'" -ErrorAction SilentlyContinue

The code will hide the message but you can Write-Host a message that outputs that exists already so you avoid the Red output and output your own message. This is because adding of a new user is not performed anyway. Maybe output to a text file the existing users can be another option.

Ricardo

Thanks Ricardo! Inserting the code in the ForEach loop did not work. I can add a Write-warning message, but it still displays the text that I want to suppress. I will simply leave it as is. I appreciate your input.