Create AD users and mailboxes from .csv file

This topic contains 2 replies, has 2 voices, and was last updated by  Bojan Zivkovic 2 years, 10 months ago.

  • Author
  • #28691

    Bojan Zivkovic

    Hi, I want to utilize the fact that New-ADUser cmdlet has parameters which accept pipeline input ByPropertyName (GivenName,SurName,SamAccountName,Title, . . .) thus I have created input .csv file with appropriate column names. The catch here is that I want to run Enable-Mailbox on newly created user account immediately after it has been created with New-ADUser cmdlet so I added another column in .csv file called MailboxDatabase where name of mailbox database is entered and used as -Database parameter in Enable-Mailbox cmdlet.

    How to perform New-ADUser and Enable-Mailbox in the most efficient way keeping in mind I want to utilize pipeline input ByPropertyName capability of New-ADUser cmdlet? Thx in advance!

  • #28692

    Simeon Iksanov

    maybe something like

    Import-Csv -Path 'filename.csv' | new-aduser -PassThru | Enable-Mailbox

  • #28717

    Bojan Zivkovic

    I have already tried this. It does not work. I am at home now but if I remember well Enable-Mailbox complained about input object type in pipeline.

You must be logged in to reply to this topic.