André Krijnen

Tag: Powershell

Restoring SharePoint databases with other schema (SharePoint 2010)

by on Aug.17, 2011, under SharePoint 2010, SharePoint Foundation

I just started out today to restore some Content Databases to test out my new created features on my development environment, to check if everything works as planned. But yet, I’ve figured out that I had some issues creating and deleting sites.

So I checked the ULS logs and nothing to see, I checked event viewer and also there no errors containing the message which I had: “Supported method not found” or something in that other.

Well I remember when I installed Service Pack 1 of SharePoint Server 2010 and tried to remove a site I had the same message. This was related to some bug or something. So I installed June CU Refresh and that worked perfectly. Well in this case I had both installed, so that shouldn’t be the problem.

So I checked the status of my Content Databases and what I noticed was that the schema version of the database wasn’t the same version as June CU Refresh. And the message was that I could update. Also the strange notice is that my Content Databases aren’t updated when you restore a database and attach it to SharePoint.

So what I did was run with powershell the following script:


$contentdb = Get-SPContentDatabase | Where-Object {$_.Name -match "WSS_ContentDB" }
Upgrade-SPContentDatabase -Identity $contentdb

Voila, content database is getting updated.

Leave a Comment :, , , , , , more...

Powershell: Update all Document Libraries with MajorVersionLimit and MajorWithMinorVersionsLimit

by on Jun.15, 2011, under blog, Powershell, SharePoint 2010

I had to write a Powershell script to run thru all sites in a Web Application to enable Versioning. As well Major as Minor versions. With of course a limit on Major and Minor versions.

Next script should do the trick:

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$siteURL = $args[0]
$site = Get-SPSite($siteURL)
foreach($web in $site.AllWebs) {
 Write-Host "Inspecting " $web.Title
 foreach ($list in $web.Lists) {
  if($list.BaseType -eq "DocumentLibrary") {
  Write-Host "Versioning enabled: " $list.EnableVersioning
  $host.UI.WriteLine()
  Write-Host "MinorVersioning Enabled: "  $list.EnableMinorVersions
  $host.UI.WriteLine()
  Write-Host "EnableModeration: " $list.EnableModeration
  $host.UI.WriteLine()
  Write-Host "Major Versions: " $list.MajorVersionLimit
  $host.UI.WriteLine()
  Write-Host "Minor Versions: " $list.MajorWithMinorVersionsLimit
  $host.UI.WriteLine()
  $list.EnableVersioning = $true
  $list.EnableMinorVersions = $true
  $list.MajorVersionLimit = 2
  $list.MajorWithMinorVersionsLimit = 5
  $list.Update()
  Write-Host $list.Title " is updated with MajorVersionLimit 2 and MajorwithMinorVersionsLimit = 5"
  }
 }
}

 

Leave a Comment :, , , , , , more...

Powershell on Windows 7

by on Aug.02, 2010, under Powershell

I didn’t know that standard Windows 7 has Powershell installed. When I started powershell I noticed the V1 version in the menu bar, but this is not the real version. I didn’t know that until I did:

Get-Host

It shows the following information:

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\> get-host

Name : ConsoleHost
Version : 2.0
InstanceId : 880b266d-2931-4ff5-9ba8-181e3ecc5ab3
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : nl-NL
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...