Jump to content

Recommended Posts

Posted

Hi All,

Has anyone got a script to bulk create unified groups in O365 for all the classes for Teams? We are looking at creating groups for over 700 classes in Teams, so that the teaching staff can just use a group to add the students, to save them adding all of the students manually in September.

Thanks

Posted (edited)

This is what I use. Export CSV for iSAMS, tweak it as required and let it run

 

   1 	#Enter a path to your import CSV file
   2 	$ADUsers = Import-csv C:\SPREADSHEET.csv 
   3 	
   4 	foreach ($User in $ADUsers)
   5 	{
   6 	
   7 	       $Username    = $User.username
   8 	       $Password    = $User.password
   9 	       $Firstname   = $User.firstname
  10 	       $Lastname    = $User.lastname
  11 	       $OU           = $User.ou
  12 		   $initials=$User.initials
  13 	
  14 	       #Check if the user account already exists in AD
  15 	       if (Get-ADUser -F {SamAccountName -eq $Username})
  16 	       {
  17 	               #If user does exist, output a warning message
  18 	               Write-Warning "A user account $Username has already exist in Active Directory."
  19 	       }
  20 	       else
  21 	       {
  22 	        #If a user does not exist then create a new user account
  23 	       
  24 	        #Account will be created in the OU listed in the $OU variable in the CSV file;
  25 	              New-ADUser `
  26 	            -SamAccountName $Username `
  27 	            -UserPrincipalName "[email protected]" `
  28 	            -Name "$Firstname $Lastname" `
  29 	            -GivenName $Firstname `
  30 	            -Surname $Lastname `
  31 	            -Enabled $True `
  32 	            -ChangePasswordAtLogon $True `
  33 	            -DisplayName "$Lastname, $Firstname" `
  34 	            -Department "Students" `
  35 		-Initials $initials `
  36 		-Description "Student User" `
  37 	            -Path $OU `
  38 		-HomeDrive "N:" `
  39 		-HomeDirectory "\\Server\Share\$Username" `
  40 	            -AccountPassword (convertto-securestring $Password -AsPlainText -Force)
  41 	
  42 	       }
  43 	}

 

CSV Like this

 


username,Password,OU,firstname,Initials,lastname,Email Address
username,randompassword,"OU= , OU= , DC= ", firstname, initials, surname, emailaddress

Edited by slugshead
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...