Connect several Sharepoint Site Collections to a Portal with PowerShell

Home > Blogs > SharePoint > Connect several Sharepoint Site Collections to a Portal with PowerShell

Connect several Sharepoint Site Collections to a Portal with PowerShell

Like This Blog 0Spike Xavier
Added by August 15, 2016

Many times when I’m working on ideas for SharePoint, I like to spin up groups of Site Collections on my development Server. In a recent class, a student asked me about this and I was describing how I created 50 student Site Collections and then connected them all to the same portal using some PowerShell. The student asked that I post a blog of how I did it so here it is. Disclaimer (I use this for development and testing only not in production!!! – so I’m not disposing of any objects)

I have already created the 50 Site Collections all under the wildcard managed path of sites and I have created the student portal at the same location so the url’s are (the …. is the web application url for example http://sharepoint.local/sites/student-01):

http://…../sites/student-01

http://…../sites/student-02

http://…../sites/student-03

http://…../sites/student04 etc…

until
http://…../sites/student-50

The portal is at:

http://…/sites/studentPortal

Each site collection’s top level site is based on the Team Site Template.

This is the navigate up control on Student 50

This-Is-the-Navigate-Up-Control-On-Student-50.png

As you can see, the navigate up control takes you to the home page of the top level site of the site collection. I am going to connect each of the 50 site collections to the Student Portal which will save me a lot of time in working with an environment to knock out some ideas on my development server.

You may also like:  Part 3 How to Import a CSV Text File into SharePoint 2013 – Creating the list in SharePoint

Get SPSite to see my Site Collections

Get-SPSite-To-See-My-Site-Collections.png

I grab all the site collections real quick with get-spsite and sort them but the url just to make sure I don’t get anything unexpected. Since I have more than 20 results, I pass in the -Limit all parameter.

Validate results of commandlet

Validate-results-of-commandlet.png

Yep, that’s what I want so I’ll put this into a variable.

Put into Variable

Put-Into-Variable.png

I declare the variable $sc and put the Get-SPSite commandlet I ran last time into it so I have all 50 site collections in the variable.

Take a look at the variable

Take-A-Look-At-the-Variable.png

I want to validate my results so I pipe the newly populated variable into a sort-object by url to make sure it’s right.
It comes back correct (not shown), so I’ll go ahead and loop through the collection and set the PortalUrl and PortalName which are properties of the SPSite object.

Loop through and set the PortalUrl Property

Loop-Through-And-Set-The-PortalUrl-Property.png

This loops through each of the site collections in the $sc variable and sets their Portal to the value I want. This is the same as going in the browser to each site collection and going Site Actions > Site Settings > Site Colleciton Administration > Connect To Portal.

You may also like:  Great SharePoint 2013 Books by Role

Set the PortalName Property

Set-The-PortalName-Property.png

Now I loop through and set the Portal Name to Student Portal.

Validate the Portal Connection

Validate-The-Portal-Connection.png

I go back to the initial Site Collection and check the Navigate Up control and “low-and-behold”, I am now connected to the Student Portal! I check a few more Site Collections just to make sure (not shown).

Click the Link Go To the Student Portal

Click-The-Link-Go-To-The-Student-Portal.png

When I clicked the link in the Navigate Up Control (last step) it took me here to the Student Portal. I always check this just in case I fat fingered the URL.
That’s it. Since this is on my development server, I’m not worrying about disposing of any objects. I will be removing all these site collections when I’m done trying out some ideas and rebooting my machine.
Enjoy!


Spike Xavier
SharePoint Instructor – Interface Technical Training
Phoenix, AZ

Videos You May Like

Agile Methodology in Project Management

0 30 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 41 1

In this Office 365 training video, instructor Spike Xavier demonstrates how to create users and manage passwords in Office 365.

Detailed Forensic Investigation of Malware Infections – April 21, 2015

1 104 1

In this IT Security training video, Security expert Mike Danseglio (CISSP / CEH) will perform several malware investigations including rootkits, botnets, viruses, and browser toolbars.

Write a Comment

Share your thoughts...

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