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

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.

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

A Simple Introduction to Cisco CML2

0 3896 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

Creating Dynamic DNS in Network Environments

0 642 1

This content is from our CompTIA Network + Video Certification Training Course. Start training today! In this video, CompTIA Network + instructor Rick Trader teaches how to create Dynamic DNS zones in Network Environments. Video Transcription: Now that we’ve installed DNS, we’ve created our DNS zones, the next step is now, how do we produce those … Continue reading Creating Dynamic DNS in Network Environments

Cable Testers and How to Use them in Network Environments

0 727 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

Write a Comment

Share your thoughts...

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