IT tutorials
 
Applications Server
 

Microsoft Sharepoint 2013 : Using SharePoint Commands (part 2) - Web Applications

1/14/2015 8:30:57 PM
- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire

Web Applications

Each site collection in SharePoint is associated with a single web application represented by the SPWebApplication object. The SPWebApplication object contains many properties that an administrator might want to look at, such as those associated with the Recycle Bin, list throttling, and status of the web application. Using the SharePoint PowerShell commands, you can list all web applications, including the Central Administration web application; create new web applications; remove web applications; and modify web application properties.

To begin, suppose you want to see all the web applications on the farm. As shown previously, by default, the Get-SPWebApplication command returns all the web applications on the farm except for the Central Administration web application. To get all web applications on a farm, including the Central Administration web application, use the Get-SPWebApplication command with the IncludeCentralAdministration switch parameter.

Getting all the web applications might not be exactly what you need. Sometimes you need a single web application. To do that, you use the –Identity parameter. This parameter is smart enough to accept the name, URL, or ID of the web application. You rarely see the –Identity parameter actually named. As shown earlier with the Format-Table command, you can omit the name of the parameter, and name only the URL or ID as shown in Figure 4.

FIGURE 4

image

The SPWebApplication has a lot of properties and methods. To see the properties of this specific web application, you can pipe it to Format-List, as shown in Figure 5.

FIGURE 5

image

As you can see, the web application object has a lot of properties. To be honest, all the SharePoint objects have a lot of properties. How are you supposed to discover all these properties and keep track of them? Fortunately, there is a command for that. Get-Member will return the members of the object passed into it via the pipeline. To determine what properties and methods are available on the SPWebApplication object, use the following command (the output is shown in Figure 6):

FIGURE 6

image
Get-SPWebApplication http://portal.contoso.com | Get-Member

If piping the output through Get-Member returns more information than one screen can handle, you can additionally pipe it to the Out-Host -paging cmdlet:

Get-SPWebApplication http://portal.contoso.com | Get-Member | out-host -paging

This command returns one page of output at a time. Press the spacebar to see the next screen. You can also scroll one line at a time by pressing the Enter key.

To access a specific property on the SPWebApplication object, use the dot notation described earlier. To access the ID of the http://portal.contoso.com web application, use the following command:

(Get-SPWebApplication http://portal.contoso.com).Id

In addition to being able to access the web applications, you can also use PowerShell to create or remove a web application. It’s clear why you might want to remove a web application, but why would you want to create a new one using PowerShell? Using PowerShell to create new web applications can be useful for repeatedly building out development or demo environments. The following New-SPWebApplication cmdlet creates a new web application, which contains many parameters — some required and some optional. To see all the parameters, use Get-Help New-SPWebApplication.

New-SPWebApplication –Name "Portal" –Port 80 –HostHeader portal.contoso.com 
–Url
http://portal.contoso.com –ApplicationPool "Default SharePoint Web App Pool"

–ApplicationPoolAccount (Get -SPManagedAccount contoso\SP_webeapps)

NOTE When running the preceding code, you may get an error indicating that you need “machine privileges.” This happens if your SharePoint 2013 Management Shell was not started with the Run as Administrator option. Without elevated permissions, SharePoint can’t always access what it needs. If you get an error like this, ensure that your Management Shell window has “Administrator:” at the beginning of the title bar.

After creating your new web application, you can use the Get-SPWebApplication command to verify that it was created properly. However, you may have noticed that the New-SPWebApplication cmdlet output the web application’s information upon completion. You could capture that object directly in a variable or pass the object onto another command via the pipeline. Notice that you are calling the Get-SPManagedAccount command to retrieve an SPManagedAccount object, which is required for the AppPool account. You can see what managed accounts you have by using the Get-SPManagedAccount command with no parameter, as shown in Figure 7.

FIGURE 7

image

Of course, creating a web application through PowerShell wouldn’t be very useful if you couldn’t similarly remove it. The Remove-SPWebApplication command follows the same verb-noun convention discussed previously, and as you might expect it is used to remove the specified web application from the farm. This command requires you to select a specific web application, which prevents the deletion of multiple applications at once. Figure 8 shows how to remove the web application you just created.

FIGURE 8

image

Notice how PowerShell prompts you before permanently destroying your data. The cmdlet offers a way to “override” this prompt, but we leave that as a future exercise once you are comfortable enough with PowerShell that you won’t accidentally destroy production data.

 
Others
 
- 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
- Microsoft Exchange Server 2013 : Designing a Successful Exchange Storage Solution - Storage Changes in Exchange 2013
- Microsoft Exchange Server 2013 : Designing a Successful Exchange Storage Solution - A Brief History of Exchange Storage
 
 
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 programming4us
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS