Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > Create Lots of Test SharePoint Sites (or Teams or Groups) with PowerShell
June 25
Create Lots of Test SharePoint Sites (or Teams or Groups) with PowerShell

Throughout my IT career I have had to create tens (or hundreds, or thousands) of objects to test something. It could be a bunch of Windows Users, a bunch of folders, files, etc. It seems like every time that happens I end up starting from scratch on the process. To stop that silly cycle I decided to make the process official by blogging it. Let’s stop this madness!

This time it started with my friend Michal Pisarek posting this tweet:

image

Orchestry needs to test their lifecycle features and he wanted to stress test it real good!

As is often the case, I see a tweet like that and my first thought is “Challenge Accepted!” The mechanics of how to create Teams with PowerShell is pretty simple but where this really gets tricky, at least for me, is the names. Especially if you’re looking at creating 20,000 like Michal is. In the past the way I’ve handled that is the old tried and true “Adjective Noun Number” formula. To get near 20,000 I wanted a long list of nouns and adjectives to pull from. I scoured the Internet and pulled together two files, nouns.txt and adjectives.txt. You can find them in this GitHub repo. Then I tack a random two digit number at the end to reduce the chance of collision. I put those files in the same directory as this PowerShell script and let ‘er rip!

Connect-PnPOnline -Url https://CONTOSO-admin.sharepoint.com -Interactive

# import the files with nouns and adjectives
$Nouns = Get-Content .\nouns.txt
$Adjectives = Get-Content .\adjectives.txt

# Number of Teams to create
$NumberOfTeams = 3
$Index = 1

while ($Index -le $NumberOfTeams) {
    # Generate Random stuff
    $TeamNoun = $Nouns | Get-Random
    $TeamAdjective = $Adjectives | Get-Random
    $TeamNumber = Get-Random -Maximum 100
    $TeamDisplayName = "$TeamAdjective $TeamNoun $TeamNumber"
    Write-Host "$Index - $TeamDisplayName"
    New-PnPTeamsTeam -DisplayName $TeamDisplayName -MailNickName $($TeamDisplayName.Replace(" ","")) -Description $TeamDisplayName -Visibility Public -AllowGiphy $true
    $Index++
}

You can find the file CreateLotsofTeams.ps1 in that same GitHub repo.

You can alter the nouns and adjectives files as you see fit. Set the the $NumberofTeams variable to how many Teams you want and you’re set. This script uses the venerable PnP.PowerShell module. You’ll need that installed and its Azure Application registered before you can run this. Be sure to change the Connect-PnPOnline line to reflect your tenant’s name, unless you actually work for Contoso.

Because of some weird timing, the current version of the PnP.PowerShell, 1.6.0, won’t work with this script as there is a bug in New-PnPTeamsTeam that prevents it from actually creating a Team. Ironic, I know. I put notes in the CreateLotsofTeams.ps1 file on how to handle that. But if you’re running it and it looks successful but no Teams are being created, look there first.

Also, for whatever reason, when you look at the Groups Sites in SharePoint they don’t show up as being Teams enabled, but they really are.

image

You can see in this crudely mocked up screenshot that the Teams are in the Teams client even though SharePoint Admin Center swears they don’t exist.

And while this script’s purpose in life is to create lots and lots of Teams, it could be easily modified to create lots and lots of anything. If you just need Groups, swap out New-PnPTeamsTeam with New-PnPMicrosoft365Group. If you just need SharePoint sites, use New-PnPTenantSite. Folders? Add-PnPFolder. I think you see where I’m going with this. Smile 

If you’re like Michal and you’re going to create 20,000 Teams, or anything, I hope you have a comfortable chair. It’s going to take a while. Michal is seeing about 1 Team a minute. It’s going to take him a couple of weeks at that pace. Almost certainly PowerShell is the bottleneck in this situation. If you’re looking at a similar situation, my advice is to open up another PowerShell window and run another instance of CreateLotsofTeams.ps1 there. And maybe run a few instances on another machine entirely. In the past that has helped me speed this things up considerably.

Enjoy.

tk

ShortURL: https://www.toddklindt.com/PoshLotsandLotsofTeams

Comments

Couponstechie


Thanks for sharing. I found a lot of interesting information here. A really good post

https://www.couponstechie.com/promo-codes/thermos-coupon
 on 8/8/2022 8:01 AM

lolbeans

A great understanding. I need to study this information <a href="https://lolbeans.online">lolbeans</a>.
 on 9/29/2022 8:30 PM

lolbeans

 on 9/29/2022 8:31 PM

DoMyHomework123

This is a very informative post. Thank you for sharing. Take the best assignment assistance on https://domyhomework123.com/do-my to submit your assignments quickly with our lightning-fast services. We offer immediate assistance to students who need help with their assessments on a variety of topics.
 on 12/4/2022 9:43 AM

Chypore

If you want to give away your console, remember to erase all of your personal information. https://geometrydashsubzero.net
 on 12/18/2022 8:53 PM

great

PowerShell is the perfect tool for you. With PowerShell, you can easily create custom sites, teams, or groups, and manage them with ease. You can even create and manage users and roles within a site, making it easy to create and manage a secure and efficient work environment. If you're looking to create test sites that are easy to use and manage, PowerShell is the perfect tool for you. https://bitlifeonline.com
 on 12/21/2022 8:20 PM

GOOD

Pattern recognition is the ability of the brain to identify order and meaning in the facts around us. https://word-search.io
 on 1/3/2023 2:24 AM

abc

nice post [links](https://devdojo.com)
 on 1/24/2023 7:01 PM

alexahills

This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information.   We can choose many types of date such as dinners, movies, clubs, etc in the way that we like. These compare with other escort services, but they are more fun than others.Her ervice can be an amazing experience to have something new in life by meeting with this woman help towards the creation of happy moments with joy, pleasure and satisfaction.
https://www.anjalityagi.com/
 on 2/1/2023 11:43 PM

finally I understand

 on 2/3/2023 5:30 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person

Twitter


Want a message when I reply to your comment? Put your Twitter handle here.

Attachments

 

 SysKit