Jan 22

SharePoint 2013 with PowerShell – Site Collection

SP2013-With-PowerShell

Working with SharePoint 2013 Site Collections (SPSite) Using PowerShell


SharePoint 2013 makes it easy for people to work together. SharePoint 2013 enables you and your employees to set up web sites to share information with others, manage documents from start to finish, and publish reports to help everyone make informed decisions. Windows PowerShell in SharePoint 2013 lets an administrator automate tasks with SharePoint web applications, site collections, sites, lists, and more and provides a command-line alternative to configuring SharePoint 2013 through Central Administration.

This article can help you in basics of working with site collections in SharePoint 2013 with PowerShell.

Creating a New Site Collection with PowerShell

Use the New-SPSite cmdlet to create a site collection. Though there are several parameters for customizing just what you want, the only required information is the address of the site collection and who owns it. Use the –URL and –OwnerAlias parameters to create a site collection at any managed path

Creating a Host Header Site Collection with PowerShell

If you’re creating a host header site collection, SharePoint won’t be able to identify the web application and managed path based on your URL, so use the –HostHeaderWebApplication parameter to tell SharePoint what web application the site collection is to be a part of.

Finding a Site Collection

Use Get-SPSite to find a site collection in SharePoint 2013. There are several different parameter sets, which means that sometimes a parameter identifies a specific way that you’re trying to use the command. For example, you can’t find a site collection by its content database and by its web application at the same time. It wouldn’t make sense to Get-SPSite. You can use either the parameter set that includes searching for a site by its content database, or you can search for a site collection by its web application.

Option 1: Find a site collection by its URL

This is the simplest usage of the Get-SPSite. Just add a URL and it will return the site collection. You’re actually adding it to the –Identity parameter, but if you only add in a single URL, then Get-SPSite knows what you are looking for.

Tip: To use regular expressions use –Regex switch like:

Option 2: Find a site collection by its web application

Note: The Limit parameter is set by default to 200. You can specify more or less, or you can use “all” to not use any limits.

Option 3: Find a site collection by its content database

You can find the site collections that are using a content database by using the –ContentDatabase parameter on Get-SPSite, or by passing in the content database to the Get-SPSite through the pipeline.

OR Try below

Option 4: Find a site collection by its property

By using the –Filter parameter, you can specify a scriptblock that can return only site collections that have values of properties that you specify. For example, if you only want to find site collections that are in maintenance mode, or site collections that require an upgrade.

Permanent link to this article: http://zappmania.in/2015/01/22/sharepoint-2013-powershell-site-collection.htm

Leave a Reply

Your email address will not be published.