Quantcast
Channel: Emad Gabriel – Emad's Blog
Viewing all articles
Browse latest Browse all 29

SharePoint PowerShell script to create SPWebApplication with Custom membership provider and Claims based authentication

$
0
0

$webAppName = “Contoso Internet Site XYZ”
$webAppUrl = “http://www.contoso.com”
$webAppPort = 80
$webAppHostHeader = “sharepoint.contoso.com”
$membershipProviderName = “OAMMembershipProvider”
$roleProviderName = “OAMRoleProvider”
$appPoolName = “ContosoAppPool”
$contentDBName = “Contoso”
$appPoolUser =  “DE\sp_AppPool”

Write-Host “Deleting Web application $webApp if it exists…”
Remove-SPWebApplication -Identity $webAppUrl -Confirm:$false -Verbose -DeleteIISSite:$true -RemoveContentDatabases:$true -ErrorAction SilentlyContinue

$formsAuthProvider = New-SPAuthenticationProvider -ASPNETMembershipProvider $membershipProviderName -ASPNETRoleProviderName $roleProviderName
$windowsAuthProvider = New-SPAuthenticationProvider
$AuthProvidersArray = $formsAuthProvider, $windowsAuthProvider

New-SPWebApplication -Name $webAppName -Port $webAppPort -HostHeader $webAppHostHeader -URL $webAppUrl -ApplicationPool $appPoolName -ApplicationPoolAccount (Get-SPManagedAccount $appPoolUser) -AllowAnonymousAccess -AuthenticationProvider $AuthProvidersArray -AuthenticationMethod NTLM -Verbose -DatabaseName $contentDBName  -ErrorVariable $ev
if($ev -ne $null)
{
    Write-Host “Web Application $webApp created successfully”
}

$webApp = get-SPWebApplication $webAppUrl
$webApp.UseClaimsAuthentication = $true
$webApp.Update()
Write-Host “Updated Web application to use claims based authentication for $webApp..”



Viewing all articles
Browse latest Browse all 29

Trending Articles