Torben Rimmer's Blog

mandag den 16. maj 2016

I have wondering on what I should write next on my blog, and came on a little idea on a serie on how to align two SharePoint 2013 environments.
We are all making new code in an test- or development environment. And for that purpurse we need to establish some valid data in the environments.

So this serie will cover all the steps to create a complete script that can take the production data, and restore it on an test/dev server.

So we should first cover our steps, before we can make a script. And if you have any comments I really like to hear your points. This serie will target those that dont have a deep knowledge in PowerShell and are looking for a copy paste solution.

So the steps are as follow:

Backup (copy style) of the production content database

Check the backup files

Dismount the content databases

Restore the content databases

Assign new site collection admins

Migrate groups and users. (If your changing AD domain)

Migrate service applications

Manage metadata

... Please ask for a service application, you like me to script.

So the way I like to make my scripts is making a master script and a funktion script. But it could be the same. I also like to make a configuration file with all my variables.

Lets make 3 files.

RunningScript.ps1

Functions.ps1

Configuration.xml

So lets have a close look at how we build the XML file.
I have build mine with all the server settings.<?xmlversion="1.0"?> <Settings> <ServerSettings><WebApp>http://contoso.com</WebApp><SQLServerFrom>SQLsServer\PRODinstance</SQLServerFrom><SQLServerTo>SQLsServer\TESTinstance</SQLServerTo><SiteColAdmin>contoso\administrator</SiteColAdmin><OldADDomain>ContosoPROD</OldADDomain><NewADDomain>ContosoTEST</NewADDomain><SQLBackupJob>SQL-Backup-JOB</SQLBackupJob><SQLRestoreJob>SQL-Restore-JOB</SQLRestoreJob></ServerSettings>

So the first step is to take the backup of the produktion database. This is bedst done by using the SMO PowerShell module.
To install the SMO please look at ...

The first part of the script we need to implement the use of the Functions.ps1 and Configuration.xml file. Note that I am using a "main" function. this is done to get an overview of the running script, and to be able to place it at the top of the script.

After in adding the script path, I include the configuration file.
Note: There are many ways to include your script path, I use the "pwd" command, but this dose not always work.
after including the files, I use the function [Run-SQL-Job]. This function is used for both backup and restore. Do mind that the account running the script need access to the production server.

torsdag den 6. juni 2013

Yesterday I hold a speech at the one of jBoye network seminar's in London, the topic (High availability with SharePoint 2013) and yes, still using the Microsoft metro style.

A great seminar with with a great view over London city. I wish my office hade this view.
Big thanks to Lau, who facilitated the meeting and to jBoye for arranging the seminar. Please visit http://www.jboye.com

The slides from the seminar is shown here and your all welcome to leave some comment.
(Please mind that all Saxo Bank specific slides have been removed)

onsdag den 10. april 2013

As in SharePoint 2010 we also in SharePoint 2013 have a lot
of jobs running and analyzing the overall health of our server.

All those rules are really nice, but in some
cases you don’t need them.

Example:

If you know that you are running with databases
over the limit and you are okay with that.

You are running with only one
service account, and is okay with that.

Your running whit a smaller page file than your physical RAM (Quit a big file if you have 48Gb)

They all have in common that you as an admin made choices, and as we all know admins never make bad decisions. So
instead of mannerly disable rules one at the time, you can just disable all and
enable the ones you need.

To disable all rules just run the script below, this will
disable all rules. To include the SharePoint SnapIn read this post

If you like, this can be combined with a xml file so you can
disable rules based on this as well. See this post to get inspiration. I would recommend using this if your maintaining a large organisation with a lot of environments.

tirsdag den 12. marts 2013

I wass asked to make a blog on an topic that was related to the checked out to <none> problem.

When SharePoint gets a deadlock in relation
to Check-In/Check-Out situation it is due to the state of the CheckOutUserID
field in the AllDocs table.

This field is set to -1, which by SharePoint
is interpreted as <none>

To fix the page and thus be able to check-in
or -out the page the CheckOutUserID must be replaced by an existing UserID from
that particular Site Collection/Web Application.

The below SQL script does that, however it
is important, that one item exist in the list in addition to the broken one, as
the ID used in the script below, will be taken from the first item having an ID
different from -1.Alternative Microsoft advice to use the ID "58"

Generic script below, only the Database name
is needed prior to running this.

USE
[Portal_XXX_content]

GO

BEGINTRY

BEGINTRANSACTION

-- Check if any documents checked out with an
invalid status

IF (SELECTCOUNT(*)

FROM AllDocs(NOLOCK)

WHERE CheckoutUserId =-1)<=
0

BEGIN

PRINT'INFO: No
document checked out with invalid user id (-1)'

END

ELSE

BEGIN

-- Check if any checked out documents
available

IF (SELECTCOUNT(*)

FROMAllDocs(NOLOCK)

WHERECheckoutUserIdISNOTNULL

ANDCheckoutUserId>-1)<=
0

BEGIN

PRINT'ERROR:
Nothing checked out so can''t find a valid user ID'

END

ELSE

BEGIN

-- Show documents that has invalid user
id

SELECT*

FROMAllDocs(NOLOCK)

WHERECheckoutUserId=-1

--Updating sharepoint field [checkoutUserId]
to a value different from -1

UPDATE[AllDocs]

SETCheckoutUserId=(SELECTTOP 1 CheckoutUserId

FROM [AllDocs](NOLOCK)

WHERECheckoutUserId>-1)

WHERECheckoutUserId=-1

SELECT*

FROMAllUserData(NOLOCK)

WHEREtp_CheckoutUserId=-1

--Updating
sharepoint field [tp_CheckoutUserId] to a value different from -1