Tuesday, June 17, 2014

Add New URL to Host-named Site Collection's Zone

In a  SharePoint hosting Web application, once sites are provisioned from hosting control panel, We got to manually add a internet zone URL with "https" to make it available over Internet.

PowerShell script to Add new URL to internet zone for a host-named site collection:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$OutPutFile = "c:\Scripts\Log"
#Get All Host Named Sites of the Hosting Web Application
$SitesColl = Get-SPSite -Limit $All | Where-Object {$_.HostHeaderIsSiteName -eq $true} 

#Loop through each site
ForEach($site in $SitesColl)
    #Check if site created in Internet Zone
    if( (Get-SPSiteURL -Identity $site.Url | Where Zone -eq "Internet").count -eq 0)
        Set-SPSiteURL -Identity $site.URL -Zone Internet -Url ($site.Url -replace "http", "https")
 Write-host "Created Internet Zone for site:"$site.Url 

        #Append to a Log
 "Created Internet Zone for site: $($site.Url) on $(get-date)" >> $OutPutFile
Scheduled the script to run for every 5 minutes using Windows Task scheduler.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...