I have just enabled SSL on our live intranet site and run the full crawl to index everything to https rather than http. Everything works fine apart from default page. It shows error, when I checked the log file it shows the following error details.
GetFileFromUrl: ArgumentException when attempting get file Url http://site url/_catalogs/masterpage/ PageLayoutName.aspx Value does not fall within the expected range.
During further investigation I found that the default page “Page layout” was still referencing to http address. The below script will update default page “page layout” URL.
$spWeb = Get-SPWeb("https://site collection URL")
$spFile = $spWeb.GetFile("https://site collection URL/Pages/default.aspx")
$spFile.CheckOut("Online",$null)
$spFile.Properties["PublishingPageLayout"] = "/_catalogs/masterpage/SCI_HomePage.aspx, Block"
$spFile.Update()
$spFile.CheckIn("Update page layout via PowerShell",[Microsoft.SharePoint.SPCheckinType]::MajorCheckIn)
$spWeb.Dispose()
In sharepoint 2010 we can upload and activate sandbox solutions. Although the sandbox solutions can slow down the page system pages execution of cause an error on page. The administrator has the ability to block the sandbox solution for a particular SharePoint 2010 farm. Once the solution is blocked it can’t be activated by any user and prompt will an error message.
For testing I create a sandbox solution and called it “sandbox 1.wsp”.
Now go to the PowerShell command line and type the following commands.
$UserCodeSvc = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
$Signature = [Microsoft.SharePoint.Administration.SPUserCodeService]::
GetSolutionSignatureFromFile($SolutionName)
$BlockedSolution = New-Object Microsoft.SharePoint.UserCode.SPBlockedSolution
-ArgumentList ($SolutionName), ($Signature), ("Solution Blocked")
$UserCodeSvc.BlockedSolutions.Add($BlockedSolution)
$UserCodeSvc.Update()
Now go to the central admin> System settings> manage user solutions, you will see that “sandbox1.wsp” is in the blocked solution list.
In SharePoint 2010 there is a recycle bin property called “RecycleBinRetentionPeriod”. This property specifies the number of days files will be stored in recycle bin and then will be deleted after that period.
I wrote a PowerShell script to set the SharePoint 2010 site retention period without much hassle.
$siteUrl = "http://eblogin.com"
Write-Host "Connecting to the site"
$SPSite = Get-SPSite | Where-Object {$_.Url -eq $siteUrl}
if($SPSite -ne $null)
{
$SPSite.WebApplication.RecycleBinEnabled = $true
$SPSite.WebApplication.RecycleBinRetentionPeriod = 20
$SPSite.WebApplication.Update()
}
$SPSite.Dispose()
Hope this will help.
The maximum file size setting will determine the maximum size of files uploaded to document libraries on the site. You can set the sharepoint 2010 web application max file size limit in many ways, but I have done this in PowerShell.
I wrote a smart PowerShell script to do this job.
$siteUrl = http://eblogin.com
Write-Host "Connecting to the site"
$SPSite = Get-SPSite | Where-Object {$_.Url -eq $siteUrl}
if($SPSite -ne $null)
{
$SPSite.WebApplication.MaximumFileSize = 200
$SPSite.WebApplication.Update()
}
$SPSite.Dispose()
Hope this will help you.
In the last post I have explained how you can change publishing site default page using PowerShell
You can also achieve same for collaboration site. In this post I explain how SharePoint 2010 collaboration site default page is set up.
$site = get-spsite "http://site URL”
$file = $site.RootWeb.GetFile("Pages/Default_Copy.aspx")
$folder = $site.RootWeb.RootFolder
$folder.WelcomePage = $file
$folder.Update()
In SharePoint 2010 publishing site you can choose the default page for that site. In the following example I will show you how you can change the default page of publishing site by using PowerShell.
$site = get-spsite "http:// site URL”
$pub = [Microsoft.SharePoint.Publishing.PublishingWeb] :: GetPublishingWeb($site.RootWeb)
$file = $pub.Web.GetFile("Pages/New_DefaultPage.aspx")
$pub.DefaultPage = $file
$pub.Update()
A user logged off after a certain period of time from sharepoint 2010 site. You can reset this timeout according to your requirement. If you need a user session to be open for more time you can always change the security time out by using PowerShell.
Open PowerShell management console and copy past the following code.
Note: change the session Time span according to your need. In this code it is setup as 1 hour and 20 minutes.
$SPSite = Get-SPSite("[URL of site collection]")
$webApp = $SPSite.WebApplication
$webApp.FormDigestSettings.Enabled = $true
$webApp.FormDigestSettings.Expires = $true
$webApp.FormDigestSettings.Timeout = New-TimeSpan -Hours 1 -Minutes 20
$webApp.Update()
Now it will enable the session expiry time to 1 hour and 20 minutes for this site collection.
I have explained below how you can setup base line and incident performance count for your sharepoint server. This will allow producing a baseline of the source depletion over a period of time. When a problem is occur, these performance encounters can be used to analyze and compare with respect to the base line data to understand any strange behavior in the system.
Baseline performance counter script
logman create counter Perf_Baseline -s %COMPUTERNAME% -o C:\PerfLogs\Perf_Baseline_%COMPUTERNAME%.blg -f bin -v mmddhhmm -cf Counter_Server.txt -si 00:01:00 -cnf 12:00:00 -b 4/29/2009 5:00AM -u "domainName\theuserid" *
Incident performance counter script
logman create counter Perf_Incident -s %COMPUTERNAME% -o C:\PerfLogs\Perf_Incident_%COMPUTERNAME%.blg -f bin -v mmddhhmm -cf Counter_Server.txt -si 00:00:10 -max 400 -u "domainName\Theuserid" *
The difference between two counters is the frequency of running. The .txt file name need to be updated purely based on server where the counter is created.
You can quickly perform site collection backup and restore using PowerShell commands. It is powerful and quick.
Back up a site collection using PowerShell
1. Make sure that the user has rights to perform backup.
2. On the “Start” click “All Programs.”
3. Now click on “Microsoft SharePoint 2010 products”.
4. Click on “SharePoint 2010 Management Shell”
5. The PowerShell command prompt will be appear , now type the following
Backup-SPSite -Identity <Name on site collection> -Path <backup file path> [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]
If you want to overwrite the previous backup, please use force.
Restore a site collection using PowerShell
1. Make sure that the user has rights to perform backup.
2. On the “Start” click “All Programs.”
3. Now click on “Microsoft SharePoint 2010 products”.
4. Click on “SharePoint 2010 Management Shell”
5. The PowerShell command prompt will be appear , now type the following
Restore-SPSite -Identity <The site collection URL> -Path <Backup file> [-DatabaseServer <Name of Database server>] [-DatabaseName <The content database name>] [-HostHeader <The Host header>] [-Force] [-GradualDelete] [-Verbose]
If you want to overwrite the existing site collection, please use force.