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 0 Spike 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/student04 etc…


The portal is at:


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

This is the navigate up control on Student 50


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.

Get SPSite to see my Site Collections


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


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

Put into Variable


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


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


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.

Set the PortalName Property


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

Validate the Portal Connection


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


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.

Spike Xavier
SharePoint Instructor – Interface Technical Training
Phoenix, AZ

Videos You May Like

A Simple Introduction to Cisco CML2

0 3859 0

Mark 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 713 1

This 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

Government Edition – Encrypting a USB Flash Drive in Windows 10

0 272 2

In this video, Security Instructor Mike Danseglio demonstrates how to use BitLocker in Window 10 to secure files on a USB Flash drive that adhere to stricter data protection requirements as found inside Government entities. BitLocker 2-day instructor-led training is now available at Interface: BITLOCK: Planning and Deploying BitLocker Drive Encryption Training Video Transcription: Hi. … Continue reading Government Edition – Encrypting a USB Flash Drive in Windows 10

Write a Comment

Share your thoughts...

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