Create AD users and mailboxes from .csv file

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Bojan Zivkovic Bojan Zivkovic 1 year, 9 months ago.

  • Author
    Posts
  • #28691
    Profile photo of Bojan Zivkovic
    Bojan Zivkovic
    Participant

    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
    Profile photo of Simeon Iksanov
    Simeon Iksanov
    Participant

    maybe something like

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

  • #28717
    Profile photo of Bojan Zivkovic
    Bojan Zivkovic
    Participant

    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.