Wednesday, November 23, 2016

Create Site collection with New Content database in SharePoint

In many scenarios you will be required to create a site collection with new Database to satisfy database growth/flexible site collection, which can later move to different web application.

Let’s see step by step how to create a SharePoint site collection with a separate content database using Powershell for SharePoint.

Step:1

Create a managed path under web application : 
Go To Central Admin >> Application Management >> Create Site Collection



Select Defined managed Paths



Enter Site collection name and Type "Explicit Inclusion"



Click on "Add Path".

Step:2

Now we need to create Content Database to host the site collection. Remember we only have Defined managed path and not created Site Collection Yet.

Run below command under Powershell window:

New-SPContentDatabase -Name "WSS_Content_test" -DatabaseServer "Servername"  -WebApplication "http://xyz:6001/test"

$ContentDatabase = Get-SPContentDatabase "WSS_Content_test"

Above command will create Content Database on SQL server.

Step:3

In Final step we need to create site collection with new content database we just created.

Define all parameters:

$url = "http://xyz:6001/test"
$ContentDatabase = "WSS_Content_test"
$WebsiteName = "Test"
$WebsiteDesc = "Site test portal"
$Template = "STS#1"
$PrimaryLogin = "domain\adminuser"
$PrimaryDisplay = "Admin"
$PrimaryEmail = "xyz@domain.com"

Execute the command:


New-SPSite -Url $url –ContentDatabase $ContentDatabase -Name $WebsiteName –Description $WebsiteDesc  -Template $Template -OwnerAlias $PrimaryLogin –OwnerEmail $PrimaryEmail

Site template we selected STS#1 is for blank website. Incase you need to explore more template types, please refer this wonderful article.

Taaada!! Site collection is created with new content database in just three steps.

Friday, February 26, 2016

Tip - In SharePoint 2013 Change the "SharePoint" text in Suitbar - SharePoint Branding

If your goal is simply to change the text, or hardcode a link without the need for any code behind, you could do it even easier with PowerShell.

Changing the SharePoint text to something else using PowerShell

Before:
















After:


















Power Shell Script:

$webApp = Get-SPWebApplication http://urlofsite:2016
$webApp.SuiteBarBrandingElementHtml = "Text Goes Here" 
$webApp.Update()
$w
Thanks we will share some more findings and articles on SharePoint 2013 branding. till then cheers.

Thursday, April 2, 2015

Move-SPUser Failed with error "The site with the id "GUID" could not be found.

Scenario

Think about this scenario,  you are trying to run the migrate user command to migrate the user from one ID to new id in he certain situation.
  1. User ID get deleted from AD and recreated but with new SID
  2. User id change from One Domain to other domain
  3. User ID got changed after her last name changed.
You run the following command:
PS C:\temp>$user = Get-SPUser -web https://webapplication url-Identity "domain\username"
PS C:\temp>Move-SPUser -Identity $user -NewAlias "domain\testuser" –IgnoreSID -Confirm:$false
Move-SPUser : The site with the id ebaf8908-78B9-4BAF-9845-56556B2BE628 could not be found.
At line:1 char:12
+ Move-SPUser <<<<  -Identity $user -NewAlias "domain\testuser" -IgnoreSID
    + CategoryInfo          : InvalidData: (Microsoft.Share...PCmdletMoveUser:
   SPCmdletMoveUser) [Move-SPUser], FileNotFoundException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletMoveUser
 

Even with Stsadm command:

stsadm.exe -o migrateuser -oldlogin "domain\user" -newlogin "domain\testuser" -ignoresidhistory
The site with the id ebaf8908-78B9-4BAF-9845-56556B2BE628 could not be found.
Now if you trying to get the details about the Site ID & run the below command:
 PS C:\temp>get-spsite  -identity "ebaf8908-78B9-4BAF-9845-56556B2BE628"
Get-SPSite : Cannot find an SPSite object with Id or Url: ebaf8908-78B9-4BAF-9845-56556B2BE628.
At line:1 char:11
+ get-spsite <<<<  ebaf8908-78B9-4BAF-9845-56556B2BE628
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:
   SPCmdletGetSite) [Get-SPSite], SPCmdletPipeBindException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite
 

Reason:

Migrate / Move user go through all sites in the content databases & User Profile. If there is any orphan sites in the content database then this issue occurred.

Identify:

If you have only few content databases in your farm then run the below mentioned script against each content DB and see if its worked.
Select * from userinfo with (nolock) where tp_siteid like '%ebaf234348-78B9-4VAF-9845-56556B2BE628%'
If you have many databases across on couple of servers then run this
EXEC sp_MsForEachDb 'use [?]; SELECT "?" AS [databasename], ID FROM [?].dbo.AllSites with (Nolock) WHERE ID = "ebaf234348-78B9-4VAF-9845-56556B2BE628"'
You will get the Database name and ID.
Server NamedatabasenameID
Database ServerContentDatabaseebaf234348-78B9-4VAF-9845-56556B2BE628

Resolution:

Method # 1

You need to detach the content Databse and re attach it back to Web app will clear the orphan.
To detach a content database by using Central Administration
  1. Verify that the user account that is performing this procedure is a member of the Farm Administrators SharePoint group.
  2. On the SharePoint Central Administration website, click Application Management.
  3. On the Application Management page, in the Databases section, click Manage content databases.
  4. Select the web application for which you want to detach a content database.
  5. Click the content database that you want to detach.
  6. On the Manage Content Database Settings page, select the Remove content database check box.
If the content database contains data, you will receive a warning. Click OK to continue with the operation.
  1. Click OK to confirm the detachment, or click Cancel to stop the operation without detaching the database.
After detaching the content database in Central Administration, the content database still exists in SQL Server.
To attach a content database by using Central Administration
  1. Verify that the user account that is being used to perform this operation is a member of the Farm Administrators SharePoint group.
  2. Start SharePoint 2010 Central Administration.
  3. On the SharePoint Central Administration website, click Application Management.
  4. On the Application Management page, in the Databases section, click Manage content databases.
  5. On the Manage Content Databases page, click Add a content database.
  6. On the Add Content Database page:
    1. Use the web Application drop-down menu to select the web application to which you want to attach a content database.
    2. Specify the database server that hosts the database.
    3. Specify the database name. If the database does not already exist, it will be created.
    4. Specify the authentication method for the database, and supply an account name and password if you are using SQL authentication.
    5. Click OK.

Method # 2

If above method failed, then you have to create a new content Database and move all working sites except orphan to the newly created Database.

Thursday, October 30, 2014

Error: Updates are currently disallowed on GET requests. To allow updates on a GET, set the ‘AllowUnsafeUpdates’ property on SPWeb.


If you are in Central Administration > Manage Web Applications and go to the General settings option,


General settings- central admin


you might run into this error:
“Updates are currently disallowed on GET requests. To allow updates on a GET, set the AllowUnsafeUpdates’ property on SPWeb. 

Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx”

error - allowunsafeupdate


“Updates are currently disallowed on GET requests” under the General Settings. The error stack trace mentioned  ‘EnsureHttpThrottleSettings’ so it means that Central Admin is trying to update these setting on a GET request for new apps that don’t already have them.

Resolution via Powershell 

Launch SharePoint Powershell and and add these lines:

$w = get-spwebapplication http://yourwebapplicationname
$w.HttpThrottleSettings
$w.Update()


The call to the HttpThrottleSettings ensures they exist and Update() saves them.

After completing these commands, you should be able to successfully launch the General Settings dialog window in Central admin.


Total Pageviews