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

Creating Users and Managing Passwords in Microsoft Office 365

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

Using Navigation Controls in a Collaboration Site in SharePoint

0 346 1

In this SharePoint training video, I want to talk about the Navigation Controls in SharePoint. They tend to fall into two kind of different categories; one with the navigation controls in a typical Collaboration Site such as a Team Site or a Project Site. These are Sites that are based on the Team Site Template … Continue reading Using Navigation Controls in a Collaboration Site in SharePoint

JavaScript for C# Developers – September 24, 2014

0 496 3

Is JavaScript worth taking the time to learn if I’m a server-side .NET developer? How much of C# carries over to JavaScript? In this recorded video from Dan Wahlin’s webinar on September 24,2014, Dan answers these questions and more while also discussing similarities between the languages, key differences, and the future of JavaScript (ES6). If … Continue reading JavaScript for C# Developers – September 24, 2014

Write a Comment

Share your thoughts...

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