locked
Mass create users help...Mostly done. RRS feed

  • Question

  • import-module activedirectory
    Import-Csv "C:\mass\date.csv" | ForEach-Object {
    $userPrincipal = $_."samAccountName" + "@yourdomain.com"
    $setpass = ConvertTo-SecureString -AsPlainText $_."password" -force
    New-ADUser `
    -Name $_."user" `
    -Path  $_."path" `
    -SamAccountName  $_."samaccountname" `
    -DisplayName $_."Displayname" `
    -Givenname $_."name" `
    -Surname $_."surname" `
    -Officephone $_."officephone" `
    -Office $_."office" `
    -Title $_."title" `
    -Department $_."department" `
    -UserPrincipalName  $userPrincipal `
    -AccountPassword $setpass `
    -Email $_."mail" `
    -ChangePasswordAtLogon $false  `
    -Enabled $true `
    -Description $_."description"
    Add-ADGroupMember -Identity $_."group" -Members $_."samaccountname";
     }

    I've got most of this complete.  2+1 items...I get a little lost when attempting to add more to a script than originally planned for.  

    Cannot get it to input into ipPhone.  Though if possible, I can copy it from "office" to ipPhone.

    I like to add a proxyAddresses SMTP:user@newdomain.com entry on every new user account.  But I cannot find the right combination to do so in the format script I have.

    If possible like to have a prompt to copyas user, then reading the information from my csv.  Is this possible?  No msexch cmdlets possible here.

    thanks for the help.

    Tuesday, September 11, 2018 9:10 PM

All replies

  • To copy a user:

    $user_tmplt = Get-AdUser usertocopy
    $user_tmplt.OfficePhone =  $_.OfficePhone
    # other attributes to set
    New-AdUser -Instance $user_tmplt

    All settings will be copied then you over-write the ones you want to change and create the new user from the modified copy.

    You do not need to quote the attributes.


    \_(ツ)_/


    • Edited by jrv Tuesday, September 11, 2018 9:44 PM
    Tuesday, September 11, 2018 9:44 PM
  • Hi,

    Thanks for your question.

    If you want to add proxyAddresses, you can use "Set-AdUser -add" to solve it.

    Set-ADUser -Identity $user.samaccountname -add @{ 'proxyAddresses' = "smtp:$($user.samaccountname)@DOMAIN.DOMAIN.COM"}
    
    

    After you create the aduser, you can use "get-aduser" cmdlet, and use "|" pipeline to pass the objects to "set-aduser" cmdlet. \

    Best Regards,

    Lee


    Just do it.

    Wednesday, September 12, 2018 9:29 AM
  • Hi,

    Thanks for your question.

    If you want to add proxyAddresses, you can use "Set-AdUser -add" to solve it.

    Set-ADUser -Identity $user.samaccountname -add @{ 'proxyAddresses' = "smtp:$($user.samaccountname)@DOMAIN.DOMAIN.COM"}
    

    After you create the aduser, you can use "get-aduser" cmdlet, and use "|" pipeline to pass the objects to "set-aduser" cmdlet. \

    Best Regards,

    Lee


    Just do it.

    How would I mesh this code into what I provided?  Would this go to the bottom?  Would it be much to ask to show me how it would look in my code?  Thanks
    Wednesday, September 12, 2018 7:34 PM
  • Hi,

    Thanks for your reply.

    You can add "Get-AdUser" cmdlet to get the aduser object you just created. And use "|" pipeline to transfer to the command i provided.

    Best Regards,

    Lee


    Just do it.

    Friday, September 14, 2018 9:54 AM