Create a Team Site in SharePoint 2010 with PowerShell including Default Security Groups
Create a Team Site in SharePoint 2010 with PowerShell including Default Security Groups
Many times when testing, or teaching SharePoint 2010 I need to spin up a quick site collection. Of course the fastest way to do this is through PowerShell using the New-SPSite commandlet and passing in a couple of parameters. Recently at one of the AZSharePoint Pros user group meetings I joked about how amazing this was except that then you had to write a bunch more PowerShell commands to get the default groups created. Luckily for me Lester from Neudesic was there and emailed me a quick PowerShell Code Snippet to save me a ton of time. (Thanks Lester!)
I wanted to do a blog post about it so I can always have the snippet handy (I edited it ever so slightly to fit my needs of course).

I run a New-SPSite Commandlet passing in the url to the new site collection, the template, the primary and secondary owner alias.

As soon as I see the URL pop up in the PowerShell window I open up the browser and voilà, there is my new site collection using the Team Site as the top level site of the site collection.

I go Site Actions> Site Settings > Site Permissions and take a look at the security settings.

I see the primary and secondary site collection administrators as well as the system account and Viewers (SharePoint Group) but no Owners, Members, and Visitors.

I adjust the script. I create a new site collection, but this time i put it into a variable $sc everything else is the same. After a few moments I type in $sc and get the URL so I open the browser and go to the newly created site collection.

Once again it's Site Actions > Site Settings > Site Permissions

I knew this was going to happen because putting the Site Collection into a variable was just setting up the next move.

I switch back to PowerShell and create a new variable $w and using the $sc.RootWeb property, put the top level SPWeb object into it, then I use the method CreateDefaultAssociatedGroups and pass in $w.site.owner and two $null parameters (thanks again Lester!)

I jump back to the browser and hit F5 to refresh the page and there they are in all their glory!!!!
Spike Xavier
SharePoint Instructor – Interface Technical Training
Phoenix, AZ
You May Also Like
New Team Site, PowerShell and SharePoint 2010, SharePoint 2010, site collections
A Simple Introduction to Cisco CML2
0 3774 0Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2
Cable Testers and How to Use them in Network Environments
0 692 1This content is from our CompTIA Network + Video Certification Training Course. Start training today! In this video, CompTIA Network + instructor Rick Trader demonstrates how to use cable testers in network environments. Let’s look at some tools that we can use to test our different cables in our environment. Cable Testers Properly Wired Connectivity … Continue reading Cable Testers and How to Use them in Network Environments
How to use AWS CloudFormation templates to automate solutions inside Amazon AWS
0 380 0In the AWS Class here at Interface, we actually build fully automated solutions with AWS CloudFormations. Here’s an overview of using AWS templates using CloudFormation. CloudFormation is basically an “infrastructure-as-code tool” where you can go into a declarative document and define all the resources that you want and feed the document into the CloudFormation … Continue reading How to use AWS CloudFormation templates to automate solutions inside Amazon AWS