Create a Team Site in SharePoint 2010 with PowerShell including Default Security Groups

Home > Blogs > SharePoint > 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

Like This Blog 0 Spike Xavier
Added by March 4, 2013

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).

 

First I use my initial method

 

First-I-Use-My-Initial-Method.png

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

 

 

Check the newly created site collection

 

Check-the-Newly-Created-Site-Collection.png

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.

 

 

Check the security groups

 

Check-the-Security-Groups.png

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

 

 

Notice the lack of Owners Members Visitors Groups?

 

Notice-the-Lack-Of-Owners-Members-Visitors-Groups.png

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.

 

 

Try again adjusting the script

 

Try-Again-Adjusting-Script.png

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.

 

 

I check the security on the second Site Collection

 

I-Check-The-Security-On-The-Second-Site-Collection.png

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

 

 

Still no Default Groups

 

Still-No-Default-Groups.png

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

 

 

Run 2 more lines of PowerShell

 

Run-2-More-Lines-of-PowerShell.png

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!)

 

 

Refresh-the-Security-Page

 

Refresh-the-Security-Page.png

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

Videos You May Like

Agile Methodology in Project Management

0 153 0

In this video, you will gain an understanding of Agile and Scrum Master Certification terminologies and concepts to help you make better decisions in your Project Management capabilities. Whether you’re a developer looking to obtain an Agile or Scrum Master Certification, or you’re a Project Manager/Product Owner who is attempting to get your product or … Continue reading Agile Methodology in Project Management

Creating Users and Managing Passwords in Microsoft Office 365

0 642 3

In this Office 365 training video, instructor Spike Xavier demonstrates how to create users and manage passwords in Office 365.   For instructor-led Office 365 training classes, see our course schedulle: Spike Xavier SharePoint Instructor – Interface Technical Training Phoenix, AZ 20347: Enabling and Managing Office 365    

Detailed Forensic Investigation of Malware Infections – April 21, 2015

4 608 5

How does an investigator hunt down and identify unknown malware? In this recording of our IT Security training webinar on April 21, 2015, Security expert Mike Danseglio (CISSP / CEH) performed several malware investigations on infected computers and identify symptoms, find root cause, and follow the leads to determine what’s happening. He demonstrated his preferred … Continue reading Detailed Forensic Investigation of Malware Infections – April 21, 2015

Write a Comment

Share your thoughts...

Please fill out the comment form below to post a reply.