IT tutorials
 
Applications Server
 

Microsoft Sharepoint 2013 : Using SharePoint Commands (part 4) - Working with Webs

1/14/2015 8:34:24 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Working with Webs

Site collections contain webs, or SPWebs if you are speaking about SharePoint PowerShell commands. Like the other main objects in the SharePoint hierarchy, you can list, add, modify, and remove webs. Administrators tend to spend a lot of time working with webs because they are so numerous and this is where end users actually do their work. The SPWeb object contains many items that end users work with, such as lists and libraries. Now is probably a good time to let you know that there are no cmdlets to access objects below the SPWeb object. This means that there are no commands for lists, libraries, or files, to name a few objects, below the SPWeb object. However, that does not mean you cannot access them via PowerShell — just that you will not find cmdlets specific to these objects. You are free to access these objects via the object model.

Listing all the webs of the farm is slightly different from listing SPWebApplications or SPSites. The Get-SPWeb cmdlet requires at least one parameter. It will not list all SPWebs on the farm if you omit the parameters; there’s just too many SPWebs in a farm for that to make sense. On the plus side, you are allowed wildcards, regular expressions (with the use of the –RegEx switch parameter), and filters (with a script block), similar to Get-SPSite. The -Identity parameter will also accept a relative path if the -Site parameter is used.

Let’s look at a few ways to list SPWebs, starting with a single web. To access a single SPWeb object, use the -Identity parameter, passing in the URL, as demonstrated in Figure 13.

FIGURE 13

image

The next example returns all the SPWebs in the farm, including any Central Administration webs, sorted by URL and displaying only the Title and URL:

Get-SPWebApplication –IncludeCentralAdministration | Get-SPSite | 
Get-SPWeb |
Sort-Object Url | Format-Table Title, Url

Figure 14 displays the results of the attempt to display all the SPWebs on the farm. As discussed earlier, the cmdlet will limit the number of objects returned to 20 for performance reasons. If the number of objects is greater than 20, a warning will be displayed. To display all the SPWebs, you need to add the -Limit property set to All for both Get-SPSite and Get-SPWeb:

FIGURE 14

image
Get-SPWebApplication –IncludeCentralAdministration | Get-SPSite –Limit All | 
Get-SPWeb –Limit All | Sort-Object Url| Format-List Title, Url

Creating a new web is similar to creating new site collections. You use the New-SPWeb command and a host of parameters to define the new SPWeb. One of these parameters, -Url, is required, but the rest are optional, such as -Name and -Template. The following command creates a new SPWeb based on the Team Site template. Once the web has been created, the SPWeb object is returned and displayed on the screen:

New-SPSWeb –Url http://portal.contoso.com/teams/IT/SP2013, -Template "STS#1" 
–Name "SP 2013 Implementation"

You cannot back up or restore an individual web; that is reserved for the site collection and farm. You can work around this limitation, however. SharePoint has content deployment functionality that enables you to automate the process of copying content from one farm to another. It does this at the SPWeb level. PowerShell has two cmdlets, Export-SPWeb and Import-SPWeb, that are built on that framework. While you can’t back up and restore webs, we can export them and import them. Be careful — these exports are not full fidelity, as their focus is on content. They won’t contain non-content pieces such as alerts, workflows, or permissions.

You just created a new web, so go ahead and export it. Use the Export-SPWeb command, passing in the -Identity and -Path parameters. The -Path parameter indicates where the exported web file will be placed, and it must include both a filename and the path:

Export-SPWeb http://portal.contoso.com/ops -Path c:\ExportWeb\opsExport.cmp

You can import the web into an existing or new web. The Import-SPWeb command requires the identity of the web to import to and the path to the exported web file. The command to import your exported site to a new web is as follows:

Import-SPWeb http://portal.contoso.com/DemoImport -Path c:\ExportWeb\opsExport.cmp

Finally, you can remove your web by using the Remove-SPWeb command. This command is similar to the Remove-SPSite command. It removes one web at a time, prompting users for confirmation along the way. You can pipe an unlimited number of SPWebs into the remove command. Don’t forget the earlier discussion of the -WhatIf parameter. As shown in Figure 15, use the -WhatIf parameter to see what would happen if you ran this command:

FIGURE 15

image
Get-SPSite | Get-SPWeb –Limit All | Remove-SPWeb –WhatIf

As you can see, the pipeline is very powerful. Be careful when you pipe objects into destructive commands. The -WhatIf parameter and PowerShell’s confirm message will help to keep you out of trouble — that is, if you pay attention.

 
Others
 
- Microsoft Sharepoint 2013 : Using SharePoint Commands (part 3) - Working with Site Collections
- Microsoft Sharepoint 2013 : Using SharePoint Commands (part 2) - Web Applications
- Microsoft Sharepoint 2013 : Using SharePoint Commands (part 1) - Working with the Farm, Working with the Farm Configuration
- Microsoft LynServer 2013 : Dependent Services and SQL - Office Web Apps Server
- Microsoft LynServer 2013 : Dependent Services and SQL - Network Dependencies (part 2) - Defining Network Sites
- Microsoft LynServer 2013 : Dependent Services and SQL - Network Dependencies (part 1) - Supporting Lync Phone Edition with DHCP
- Microsoft Exchange Server 2013 : Designing a Successful Exchange Storage Solution (part 3) - Selecting the Right Storage Hardware, Storage Validation Using Jetstress
- Microsoft Exchange Server 2013 : Designing a Successful Exchange Storage Solution (part 2) - Making Sense of the Exchange Mailbox Server Role Requirements Calculator
- Microsoft Exchange Server 2013 : Designing a Successful Exchange Storage Solution (part 1) - Requirements Gathering
- Microsoft Exchange Server 2013 : Designing a Successful Exchange Storage Solution - Storage Improvements in Exchange Server 2013
 
 
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
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us