Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Managing SharePoint 2010 with Windows PowerShell : Managing SharePoint 2010 Sites (part 1)

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
4/22/2013 5:18:44 PM
Let’s see which cmdlets are provided for handling site collections:
PS > Get-Command -Noun SPSite

CommandType   Name             Definition
-----------   ----             ----------
Cmdlet        Backup-SPSite    Backup-SPSite [-Identity] <SPSitePipeBind>
Cmdlet        Get-SPSite       Get-SPSite [-Limit <String>] [-WebApplicat
Cmdlet        Move-SPSite      Move-SPSite [-Identity] <SPSitePipeBind> -
Cmdlet        New-SPSite       New-SPSite [-Url] <String> [-Language <UIn
Cmdlet        Remove-SPSite    Remove-SPSite [-Identity] <SPSitePipeBind>
Cmdlet        Restore-SPSite   Restore-SPSite [-Identity] <String> -Path
Cmdlet        Set-SPSite       Set-SPSite [-Identity] <SPSitePipeBind> [-

We’ll start with the Set-SPSite cmdlet.

Configuring a Site Collection in SharePoint 2010

The Set-SPSite cmdlet is used to configure a site collection. This cmdlet supports a few interesting parameters that you can use to change a site collection. Here’s how to add a secondary owner to a site collection:

PS > Set-SPSite -Identity http://SPServer01 -SecondaryOwnerAlias powershell\nigo


					  

In this example, we use the SecondaryOwnerAlias parameter and set the domain user powershell\nigo as the secondary owner of the site collection.

Another nice feature is the UserAcountDirectoryPath parameter, which defines a scope for user accounts, meaning that only accounts within the organizational unit can be added as members of the site collection. People pickers will also be limited to this scope. The following example limits the scope to the Company/Site/Users organizational unit.

PS > Set-SPSite -Identity http://SPServer01 '
>> -UserAccountDirectoryPath "OU=Users,OU=Site,OU=Company,DC=Powershell,DC=nu"


					  

If we now try searching for users through the people picker in SharePoint, we will be able to find users only within the scope and users already added to the site collection.

Note

Users added before the scope change is committed will still be able to access the site collection.


Backing Up and Restoring Site Collections in SharePoint 2010

You can take a backup of a site collection with the Backup-SPSite cmdlet and restore a site collection from a backup file using the Restore-SPSite cmdlet. The use of these cmdlets is pretty straightforward.

Here is an example of taking a backup of a site collection:

PS > Backup-SPSite -Identity http://SPServer01 -Path C:\Backup\siteCollection.bak


					  

By default, the site collection is temporarily set to read-only, so that no changes can be made while the backup is performed. The Backup-SPSite cmdlet also supports the NoSiteLock switch parameter, which specifies that the site collection not be locked during the backup, however, this parameter is not recommended using if users are writing to the site collection while a backup is performed. Using the UseSqlSnapshot parameter is recommended if the database server hosting the content database supports database snapshots.

After you have a backup file of the site collection, you can use the Restore-SPSite cmdlet to restore the site collection:

PS > Restore-SPSite -Identity http://SPServer01 -Path C:\Backup\siteCollection.bak

Confirm
Are you sure you want to perform this action?
Performing operation "Restore-SPSite" on Target "http://SPServer01".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"): Y


					  

Typing Y or pressing ENTER at the confirmation prompt performs the action and restores the site collection.

Creating a New Site Collection

To create new site collection, use the New-SPSite cmdlet. This cmdlet has two required parameters: Url and OwnerAlias. You can specify a template with the Template parameter. It is also possible to specify a content database to use with the ContentDatabase parameter.

Here is an example of creating a new site collection:

PS > New-SPSite -Url http://SPServer01:5077 '
>> -OwnerAlias powershell\administrator -Template "STS#0"

Url
---
http://spserver01:5077

Here, we point the URL to the root of an existing web application, set the owner for the site collection, and specify a template. The template name might look a little strange, but if you take a quick peek with the Get-SPWebTemplate cmdlet, you will see which template we are using.

Removing Site Collections in SharePoint 2010

The Remove-SPSite cmdlet completely deletes an existing site collection and all sites. The cmdlet supports the GradualDelete switch parameter, which removes the site collection gradually, reducing system load. This parameter is recommended for deleting large sites.

PS > Remove-SPSite -Identity http://SPServer01:5077 -GradualDelete -Confirm:$False


					  

In this example, we delete the new site collection that we previously created. We also add the GradualDelete switch parameter and set the Confirm switch parameter to $False so that no confirmation is required.

Other -----------------
- System Center Configuration Manager 2007 : Reporting Configuration (part 3) - Console Reporting Links, Relational Database Concepts
- System Center Configuration Manager 2007 : Reporting Configuration (part 2) - Copying ConfigMgr Classic Reports to SQL Reporting Services, Report Categories
- System Center Configuration Manager 2007 : Reporting Configuration (part 1) - Configuring the Reporting Point for Classic Reporting, SRS Reporting
- System Center Configuration Manager 2007 : ConfigMgr Classic Reports Versus SQL Reporting Services
- Deploying the Client for Microsoft Exchange Server 2007 : Deploying with Microsoft Systems Management Server, Managing Postdeployment Tasks
- Deploying the Client for Microsoft Exchange Server 2007 : Installing the Exchange Client, Pushing Client Software with Windows Server 2003 Group Policies
- Integrating BizTalk Server 2010 and Microsoft Dynamics CRM : Communicating from Dynamics CRM to BizTalk Server (part 3) - Registering the plugin, Testing the plugin
- Integrating BizTalk Server 2010 and Microsoft Dynamics CRM : Communicating from Dynamics CRM to BizTalk Server (part 2) - Writing the Dynamics CRM plugin
- Integrating BizTalk Server 2010 and Microsoft Dynamics CRM : Communicating from Dynamics CRM to BizTalk Server (part 1) - Setup
- SharePoint 2010 : Farm Governance - Configuring a Managed account
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server