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 2)

- 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:20:25 PM

Finally, let’s take a look at the cmdlets used to manage sites in SharePoint 2010. All the cmdlets for managing sites in SharePoint 2010 use the SPWeb noun.

PS > Get-Command -Noun SPWeb

CommandType   Name           Definition
-----------   ----           ----------
Cmdlet        Export-SPWeb   Export-SPWeb [-Identity] <SPWebPipeBi
Cmdlet        Get-SPWeb      Get-SPWeb [[-Identity] <SPWebPipeBind
Cmdlet        Import-SPWeb   Import-SPWeb [-Identity] <SPWebPipeBi
Cmdlet        New-SPWeb      New-SPWeb [-Url] <String> [-Language
Cmdlet        Remove-SPWeb   Remove-SPWeb [-Identity] <SPWebPipeBi
Cmdlet        Set-SPWeb      Set-SPWeb [-Identity] <SPWebPipeBind>

Let’s look at how to use each of these, starting with New-SPWeb.

Creating Sites in SharePoint 2010

The New-SPWeb cmdlet creates a new site in an existing site collection. The only parameter that is required is the URL, which must be in an existing site collection and unique. You can also specify the language, site template, name, and description, as well as set unique permissions, add the site to the parent site’s Quick Launch bar, and set the top navigation bar options.

Here’s an example of creating a new site:

PS > New-SPWeb -Url http://SPServer01/NewSite -Template "STS#0" '

>> -Name "New Site" -Description "My New Site" -AddToTopNav -UseParentTopNav

Url
---
http://spserver01/NewSite


					  

In this example, we set the template to use. Next, we specify the name and description of the site. Finally, we use the AddToTopNav switch parameter to add the site to the top-level navigation bar and the UseParentTopNav switch parameter to specify that the site uses the same top-level navigation bar as the parent site.

Note

If you do not set a template when creating the new site, you can add it later, either in the browser or with the Set-SPWeb cmdlet.


Configuring Sites in SharePoint 2010

The Set-SPWeb cmdlet lets you configure existing sites in SharePoint 2010. The following example changes the description of an existing site.

PS > Get-SPWeb http://SPServer01/NewSite | Select-Object -Property Description

Description
-----------
My New Site

PS > Get-SPWeb http://SPServer01/NewSite |
>> Set-SPWeb -Description "A New Description"

PS > Get-SPWeb http://SPServer01/NewSite | Select-Object -Property Description

Description
-----------
A New Description


					  

First, we use Get-SPWeb and pipe the object to the Select-Object cmdlet to retrieve the current value of the Description property. We then use the Set-SPWeb cmdlet to change the site’s description. Finally, we verify that the change occurred by retrieving the site’s description again.

Exporting and Importing Sites in SharePoint 2010

With the Export-SPWeb cmdlet, you can export a site, as follows:

PS > Export-SPWeb -Identity http://SPServer01/NewSite '
>> -Path C:\Backup\spWebBackup.bak

This example exports an entire site to a backup file. It is also possible to export specific content from a site, such as lists, document libraries, and even list items. You use the ItemUrl parameter to export lists or list items from a site. Here is an example of exporting a list called Calendar from a site:

PS > Export-SPWeb -Identity http://SPServer01/NewSite '
>> -ItemUrl "Lists/Calendar" -Path C:\Backup\spWebCalendar.bak

The Export-SPWeb cmdlet also supports the IncludeUserSecurity switch parameter, which allows you to include access control lists for all items.

By default, Export-SPWeb exports the last major version of a list item, but you can change this by setting the IncludeVersions parameter to include the current version, last major and minor version, or all versions of each item.

Once you have an export file, you can use the Import-SPWeb cmdlet to import it into a site. Importing a site works as long as you specify a site collection that contains a matching template; otherwise, an error occurs.

In the following example, we will delete the Calendar list in SharePoint 2010 and perform an import with the Import-SPWeb cmdlet. Figure 1 shows how to delete a list in SharePoint 2010.

Figure 1. Deleting the Calendar list

Now that the list is removed, we can go ahead and run Import-SPWeb:

PS > Import-SPWeb -Identity http://SPServer01/NewSite '
>> -Path C:\Backup\spWebCalendar.bak

The Import-SPWeb cmdlet also supports the UpdateVersions parameter, which allows you to specify how to handle items that already exist in a list. The possible values are Append, Overwrite, and Ignore.

Removing Sites in SharePoint 2010

The Remove-SPWeb cmdlet removes a specific site from SharePoint 2010. If the top-level site is deleted, the site collection is also removed. Here is an example of running this cmdlet:

PS > Remove-SPWeb -Identity http://SPServer01/NewSite -Confirm:$false
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