Viser opslag med etiketten Sharepoint2013. Vis alle opslag
Viser opslag med etiketten Sharepoint2013. Vis alle opslag

mandag den 16. maj 2016

SharePoint 2013 alignment (1/?)

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:
  1. Backup (copy style) of the production content database
  2. Check the backup files
  3. Dismount the content databases
  4. Restore the content databases
  5. Assign new site collection admins
  6. Migrate groups and users. (If your changing AD domain)
  7. Migrate service applications
    1. Manage metadata
    2. ... 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.
<?xml version="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.

Using the RunningScript.ps1
function main
{
  cls
  Write-Host -ForegroundColor Blue "Starting AligmentScript"
  $bits = pwd
  . "$bits\Functions.ps1"
 
  [xml]$xmlConfiguration = Get-Content "$bits\Configuration.xml"
  Run-SQL-Job "$xmlConfiguration.Settings.ServerSettings.SQLServerFrom" "$xmlConfiguration.Settings.ServerSettings.SQLBackupJob"
{

 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.

The function looks like this:
function Run-SQL-Job
(
  $instancename,
  $jobname
)
{
 
$db = "MSDB"
   try
   {
 
   $sqlConnection = new-object System.Data.SqlClient.SqlConnection
     $sqlConnection.ConnectionString = 'server=' + $instancename + ';integrated security=TRUE;database=' + $db
     $sqlConnection.Open()
 
   Start-Sleep -s 1
     $sqlCommand = new-object System.Data.SqlClient.SqlCommand
     $sqlCommand.CommandTimeout = 120
     $sqlCommand.Connection = $sqlConnection
    
$sqlCommand.CommandText = "EXEC dbo.sp_start_job N'$JobName'"
     Write-Host "Executing Job => $jobname..."
     $result = $sqlCommand.ExecuteNonQuery() 
     $sqlConnection.Close()
   }
 
  catch
   {
 
   Write-Eventlog -Logname 'Application' -Source 'Application' -EventID 19002 -EntryType Error -Message "Start SQL job :$jobname Failed"
  }
 
# Preload Sql server SMO Assemblies
  $null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Connect ionInfo")
  $null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum ")
  $null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
  # Initilize SMO Objects
  $server = New-Object Microsoft.SqlServer.Management.Smo.Server $instancename
  $i = 0
 
while ($i -ne 100)
  {
    $agent = $server.JobServer.Jobs
 
  if($agent){$i = 100}
    else
    {
 
    Start-Sleep -s 1
      $i += 1
    }
  }
 
$Restore = $agent | Where-Object {$_.Name -eq $jobname}
  $Today = Get-Date
  $continue = $true
 
# Get Time Value to Start and Stop
  $ActiveDateTime=[datetime]::Parse((Get-Date -Format 'HH:MM'))
  $StopDateTime=$ActiveDateTime.addminutes(1)
 
$StopTime=$StopDateTime.toString("HH:MM")
  if ($Restore -eq $null)
  {
 
   Write-host "$jobname does not exist on $instancename"
    $continue = $false
  }
 
if ($continue){write-host -ForegroundColor Blue "$jobname Job is Executing. Please Wait.." -NoNewline}
  while ($continue)
{
$Restore.Refresh()
 
# if Job Completed Successfully     
  if ($Restore.CurrentRunStatus.value__ -eq 4 -and $Restore.LastRunDate -gt $Today.AddDays(-1) -and $Restore.LastRunOutcome -eq "Succeeded")
  {
 
   Write-host "$jobname complete."
    $continue = $false
  }
 
# if Job is curently executing     
  elseif ($Restore.CurrentRunStatus.value__ -eq 1)
  {
 
  Write-host -ForegroundColor Blue "." -NoNewline
    start-Sleep -s 5
  }
 
# if Job Suspended    
  elseif ($Restore.CurrentRunStatus.value__ -eq 5)
  {
 
   Write-host "$jobname Job has been suspended."
    $continue = $false
  }
 
# if Job Cancelled     
  elseif ($Restore.CurrentRunStatus.value__ -eq 4 -and $Restore.LastRunOutcome -eq "Cancelled")
  {
 
    Write-host "$jobname Job has been Cancelled"
     $continue = $false
  }
 }
}
 

 

onsdag den 10. april 2013

Disable all Health analyzer rules in SharePoint 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.

PowerShell Script:
------------------------------
function main
{
$healthList = [Microsoft.SharePoint.Administration.Health.SPHealthRulesList]::Local.Items
 foreach ($Listitem in $healthList)
 {
  Write-Host -ForegroundColor Green $listitem.Id ": " -NoNewline
  if ($Listitem["HealthRuleCheckEnabled"] -ne $false)
  {
   Write-Host -ForegroundColor Magenta "Disable job"
   $Listitem["HealthRuleCheckEnabled"] = $false
   $Listitem.Update()
  }
  else
  {
   Write-Host -ForegroundColor White Done -BackgroundColor Black
  }
 }
}

Have fun with PowerShell 


mandag den 4. marts 2013

SharePoint 2013 on Azure



So this blog post is about Windows new Azure platform. And will not have any technical contend. But take it as a fun story on me trying to figure out the price for a server on Windows Azure.
   
I as a Microsoft Bizspark Partner was looking for an easy way to set up a new SharePoint 2013 installation on Azure. Just to start a POC on hosting SharePoint 2013 server. So i went to the portal administration panel to create my first windows machine, so I could get started.

My first concern was with the size, I should at least start with the minimums requirements for SharePoint 2013, since I need to present this solution to some customers and need to show that my solution is running fast and problem free. And also not get in to a discussion about my solution is running on at testing environment and it of course would be much faster for the customer. So to find out how big my installation needed to be I went to Microsoft to find the minimums requirements, just to discover that its good sense and fully lives up to my expatiation. So for the smallest installation I need 4 CPU and 8GB RAM, this should be no problem. (I would strongly recommend a larger server)
http://technet.microsoft.com/en-us/library/cc262485.aspx

As a Bizspark Partner I have some benefit regarding Azure as I can use some servers for free so I can get up and running before I have to pay for the services I need. And trust me I have no problem with paying for a service. So I went and signed up for Azure to get started. I thought to myself this is no problem, Microsoft have this under control so it is just for me to start. And my expectation was correct, under offers I found a link and with no problem I was up and running. This process got me smiling. 

So to set up A virtual machine on Azure just go to the administration portal click the big and easy to find plus sign and pick Virtual machines (This of course demand that you sign up for the review program first). So I thought to myself. Microsoft wants all to use SharePoint so they will make this easy for me. I will just have to pick an image and off I go right.

But I was soon to get a lot wiser. First up to choose the Image, just to find that I can choose a SQL image, a windows image even a Linux image, but not a SharePoint image? So I figured out that they properly haven made this one jet, so I will just need to create this myself. So I picked a clean windows 2012 server. And then I needed to choose my Virtual machine size. And then I got a little confused. I could choose from the following sizes.


Okay not the biggest machines in the world. I  can as a bizspark partner choose extra small or small. So to have the minimums demand in the back of my head, I found that I needed the extra large server to install a single instance of SharePoint 2013. (BTW why can have a server with 768MB of RAM, that's not even enough to run a decent IIS).
So looking at the largest instance I can start using being the small server having 1 CPU and 1.75BG RAM it would be a little hard to get something installed. So okay I thought, to get something up and running I need to pay for my service.

So to make a simple calculation on what I need to pay, for my minimum installation. I went to the calculation site to look at some numbers. For a single SharePoint installation with everything on the same box I need an Extra Large server, since the Large server with 4 CPU’s only have 7GB RAM. Remembering that the minimum RAM I need is 8GB.

After finding out that I needed an Extra Large server, I wanted to figure out what my monthly bill would be. I navigated to the calculator and found out that I had to pay. $460,80 per month for a single virtual server to run SharePoint 2013. (I know that I should use Office 365 for Office installation, and with good sense.) But I wanted to have full control over my installation and did not want to invest in hardware.

Azure is a good and fast system especial if you are using the "websites, databases or any other service", but in my sense it's not really mature for a windows installation. Except if you want to pay some really heavy prices. For my startup installation, I would need at least two severs one for SharePoint and one for SQL. So the price would be $921 on a monthly base. That’s a really heavy price to have as a startup.

So what is the key learning’s.

Azure is a really good alternative to buying servers yourself, and get them hosted. But I think the price is a little high for the machines you need. In my case I would have to spend almost $11.000 per year for two servers. Can I do this better? Well this depend on how good price I can get in a hosting company like Rackspace. I can get a decent server for less than $2.500 that matches the demands for running SharePoint and SQ. So I just need to find a place in the country to store my servers for about $5.000 a year. Well maybe it’s okay to pay a little more be-course my servers will hopeful work for more than one year.

So what will I do. Am not sure, I might call up Microsoft and ask if they can raise the number of RAM in there large server, this way it will support most of the applications for a little less on monthly base.
Else I will go and figure out on how to use O365 and SharePoint 2013.

onsdag den 27. februar 2013

Speech at jBoye

Today I hold a speech at the one of jBoye network seminar's, on the topic (High availability with SharePoint 2013). A fun presentation as this was my first try on using the Microsoft metro style.

For the ones that know Danish will be able to read the slides. but your all welcome to leave a comment.
(Please mind that all Saxo Bank specific slides have been removed)

Slides