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 Web Applications

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/4/2012 6:22:12 PM
Four Windows PowerShell cmdlets are available for working with web applications in SharePoint 2010. You can retrieve a list of all the web application cmdlets using the Get-Command cmdlet with the noun SPWebApplication:
PS > Get-Command -Noun SPWebApplication

CommandType Name                    Definition
----------- ----                    ----------
Cmdlet      Get-SPWebApplication    Get-SPWebApplication [[-Identity] <
Cmdlet      New-SPWebApplication    New-SPWebApplication -Name <String>
Cmdlet      Remove-SPWebApplication Remove-SPWebApplication [-Identity]
Cmdlet      Set-SPWebApplication    Set-SPWebApplication [-Identity] <S

We’ll look at each of these cmdlets, starting with Get-SPWebApplication.

Getting Web Applications in SharePoint 2010

The Get-SPWebApplication cmdlet returns the web applications in SharePoint 2010. You can use the Identity parameter to return a specific web application. If you don’t specify a web application, all web applications are returned:

PS > Get-SPWebApplication

DisplayName                    Url
-----------                    ---
SharePoint - 80                http://spserver01/

By default, Central Administration is excluded from the set of returned web applications. Using the IncludeCentralAdministration switch parameter forces the Central Administration web application to be included:

PS > Get-SPWebApplication -IncludeCentralAdministration

DisplayName                    Url
-----------                    ---
SharePoint - 80                http://spserver01/
SharePoint Central Administ... http://spserver01:23815/

Modifying Web Applications in SharePoint 2010

To configure web applications in SharePoint 2010, use the Set-SPWebApplication cmdlet. This cmdlet supports a variety of parameters corresponding to different configuration settings of web applications, such as e-mail addresses, SMTP server, and time zone.

First, let’s look at how to configure the From and Reply-to e-mail addresses. When configuring the e-mail addresses used by the web application, you must specify an SMTP server to use.

PS > Get-SPWebApplication -Identity http://SPServer01 |
>> Set-SPWebApplication -OutgoingEmailAddress [email protected] `
>> -ReplyToEmailAddress [email protected] -SMTPServer ExcServer01

In this example, we use Get-SPWebApplication to retrieve a specific web application, and then pipe the object to the Set-SPWebApplication cmdlet, where we use the SMTPServer parameter to specify which SMTP server to use. We also specify the From and Reply-to e-mail addresses that should be used by the web application. Figure 1 shows what the configuration looks like in Central Administration.

Figure 1. Setting the From e-mail address, Reply-to e-mail address, and SMTP mail server through PowerShell


It is also possible to allow anonymous access with the Set-WebApplication cmdlet. Allowing anonymous access at the web application level enables individual site collection administrators to turn on anonymous access.

PS > Get-SPWebApplication -Identity http://SPServer01 |
>> Set-SPWebApplication -AllowAnonymousAccess -Zone Default

To disable anonymous access, use the same switch parameter followed by :$False:

PS > Get-SPWebApplication -Identity http://SPServer01 |
>> Set-SPWebApplication -AllowAnonymousAccess:$False -Zone Default

Caution

If anonymous access is turned off when using Forms-based authentication, Formsaware client applications may fail to authenticate correctly.


Use the Set-SPWebApplication cmdlet’s DefaultTimeZone parameter to set the time zone that should be used for new site collections:

PS > Get-SPWebApplication -Identity http://SPServer01 |
>> Set-SPWebApplication -DefaultTimeZone 4

In this example, we use the DefaultTimeZone parameter to set the time zone used by new site collections to 4, which corresponds to Western Europe Standard Time. You can list the other values for time zones using the SPRegionalSettings class as demonstrated below.

PS > [Microsoft.SharePoint.SPregionalSettings]::Globaltimezones

Creating a New Web Application in SharePoint 2010

You can create new web applications in SharePoint 2010 with the NewSPWebApplication cmdlet. This cmdlet has several parameters for configuring the new web application, including the following:

  • The Name parameter specifies the name of the new web application.

  • The Port parameter sets the port from which the web application can be accessed.

  • The ApplicationPool parameter specifies the application pool to use. If the application pool does not exist, a new application pool will be created.

  • When creating new application pools with the New-SPWebApplication cmdlet, an application pool account must be specified. You can specify the account through the ApplicationPoolAccount parameter.

Here is a basic example showing how to create a web application through Windows PowerShell:

PS > New-SPWebApplication -Name "My WebApplication" -Port 5077 `
>> -ApplicationPool "MyAppPool" `
>> -ApplicationPoolAccount (Get-SPManagedAccount powershell\managedaccount)

DisplayName                    Url
-----------                    ---
My WebApplication              http://spserver01:5077/

In this example, we use the Get-SPManagedAccount cmdlet to retrieve an account that is registered in the configuration database.

When the command is run, a content database is also created. Since we didn’t specify a name for the content database in this example, a name will be autogenerated in the format WSS_Content_<GUID>. Alternatively, you can specify a custom name through the DatabaseName parameter.

Removing a Web Application in SharePoint 2010

The Remove-SPWebApplication cmdlet removes an existing web application. You can use the Zone parameter to remove a specific zone. If the zone is not specified, all zones are removed. The cmdlet also supports switch parameters that allow you to delete the IIS web site associated with the target zone (or all zones) and the content database associated with the web application. Here’s an example:

PS > Remove-SPWebApplication -Identity http://SPServer01:5077 '
>> -DeleteIISSite -RemoveContentDatabases

Confirm
Are you sure you want to perform this action?
Performing operation "Remove-SPWebApplication" on Target "My WebApplication".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"): Y


					  

In this example, we remove the web application that we previously created. We also add the DeleteIISSite and RemoveContentDatabase switch parameters to remove the IIS web site and content database associated with the web application. As with the other removal cmdlets, Windows PowerShell prompts for a confirmation before the command is executed.

Other -----------------
- Managing SharePoint 2010 with Windows PowerShell : Managing Permissions in SharePoint 2010, Managing Content Databases in SharePoint 2010
- BizTalk 2010 : ASDK SQL adapter examples (part 4) - Composite Operations
- BizTalk 2010 : ASDK SQL adapter examples (part 3) - Query notification and multiple result sets
- BizTalk 2010 : ASDK SQL adapter examples (part 2) - Select, Table Valued Function, and Execute Reader
- BizTalk 2010 : ASDK SQL adapter examples (part 1) - TypedPolling and debatching
- Microsoft Dynamics AX 2009 : Integration with Microsoft Office - Sending email using Outlook
- Microsoft Dynamics AX 2009 : Integration with Microsoft Office - Exporting data to Microsoft Project
- Microsoft Content Management Server : The ASP.NET Stager Application (part 3) - Staging Attachments
- Microsoft Content Management Server : The ASP.NET Stager Application (part 2) - Staging Channels and Postings
- Microsoft Content Management Server : The ASP.NET Stager Application (part 1) - The DotNetSiteStager Project, Recording Messages to a Log File
 
 
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