PowerShell to update custom Sign In Page for SharePoint web application
Set-PSDebug -Strict
Set-StrictMode -Version Latest
function Ensure-WebApplicationSignInURL
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]$webAppURL,
[Parameter(Mandatory=$true)]
[string]$signInURL
)
$webApp = Get-SPWebApplication $webAppURL
if(($webApp.IisSettings['Default'].ClaimsAuthenticationRedirectionUrl) -eq $Null)
{
Write-Host "Updating Sign-In Page URL for web application $($webAppURL)"
Set-SPWebApplication -Identity $webapp.Name -Zone:Default -SignInRedirectURL $signInURL
Write-Host "Sucessfully updated Sign-In Page URL for $($webAppURL)" -ForegroundColor Green
}
else
{
Write-Host "Skipped updating Sign-In page URL as it already exists" -ForegroundColor Yellow
}
}
Ensure-WebApplicationSignInURL -webAppURL "WEBAPPURL" -signInURL "SIGNINPAGEURL"