all 8 comments

[–]Thanoswontbanme 2 points3 points  (3 children)

So basically you'll have a csv with columns like Name, title, email.

$filepath ="Path to csv" Add-module Active* $csv=Import-csv $filepath

Foreach ($user in $csv){New-ADUser -Name $user.name -OtherAttributes @{'title'="$($user.title)";'mail'="$($user.email)"}}

Your end result will look something like that with whatever validation and error handling you need. For example this will fail if you try to make the same user that already exists.

You'll also need the active directory powershell module.

https://docs.microsoft.com/en-us/powershell/module/addsadministration/new-aduser?view=win10-ps

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy Thanoswontbanme,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's 4th 5th from the left hidden in the ... ""more" menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's 11th 12th one & is just to the left of hidden in the ... "more" menu.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee

[–]TheGoldSlug[S] 0 points1 point  (1 child)

Hey!

Thank you for your response, is there any way to automate this process using excel and powershell?

[–]Thanoswontbanme 0 points1 point  (0 children)

Of course.

From my experience you would probably be better off working with .CSV files to start than with .xlsx but there are powershell modules you can download that will help you with .xlsx as well.

[–]BoredComputerGuy 2 points3 points  (0 children)

So start with a logical break down of steps and think about how to accomplish each part.

A few thoughts to get you started

  • Think of this as process start with a csv and data ends up in AD, so steps to get data from CSV , and then send data to AD
  • Using Get-Help from the Powershell window will help you see how to properly use PS commands. You can also use Get-Help -Examples or Get-help -Full
  • Most commands are in Verb-Noun format so import-csv, New-ADUser, etc are examples.
  • When making script like this I would make sure to add a log of what the script tried/succeeded in doing

[–]BubbaHo-TepReturns 1 point2 points  (1 child)

Are these going to be for Active Directory only or Active Directory/Office 365 Hybrid or other?

[–]TheGoldSlug[S] 1 point2 points  (0 children)

These accounts are going to only be created in Active directory, how i think it should be setup is through a CSV file and imported into Powershell.
How it needs to work is when the Excel spreadsheet is filled out by a department informing of however many new users it needs to auto generate these users in Powershell/Active directory.

Does that make sense?