programming4us
 
Applications Server
 

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

1/14/2015 8:30:57 PM

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
 
 
REVIEW
 
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- Sigma 24mm f/1.4 DG HSM Art

- Canon EF11-24mm f/4L USM

- Creative Sound Blaster Roar 2

- Alienware 17 - Dell's Alienware laptops

- Smartwatch : Wellograph

- Xiaomi Redmi 2
 
VIDEO TUTORIAL
 
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
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
 
Top 10
 
- Setup Free Media Server To Stream Videos To DLNA Compatible TV, Xbox 360 & PS3 (Play Station 3)
- How To Install Android Market & Google Apps On Kindle Fire
- How To Make Ubuntu Look Like Windows 7
- How To Add A New Account in MS Outlook 2013
- Get Android & Mac OS X Style Gadgets For Windows 7 & Windows 8 With XWidget
- How To Activate Microsoft Office 2013
- How To Install Actual Facebook App On Kindle Fire
- How To Create, View And Edit Microsoft Office Files On Kindle Fire
- Download Attractive Business PowerPoint Templates For Free At SlideHunter
- How To Use And Enable Hibernate & Sleep Mode In Windows 8