Wednesday, 22 January 2014

Powershell to restore a site collection without changing the existing security group members

Recently I had an requirement to update a wiki site collection from live, using PowerShell backup and restore, to a training environment.  The requirement further stated that the memberships of the existing training site should be kept.

Though this seems like an fairly easy requirement it turned out not to be something that could be done with Backup-SPSite and Restore-SPSite code, so I developed the code below, which works in a test environment I created.

Add-PSSnapin Microsoft.SharePoint.Powershell

$oldm = Get-SPuser -Web "http://win-l31vicrc3b5/" -Group "Team Site Members"
$oldo = Get-SPuser -Web "http://win-l31vicrc3b5/" -Group "Team Site Owners"
$oldv = Get-SPuser -Web "http://win-l31vicrc3b5/" -Group "Team Site Visitors"

Restore-SPSite "http://win-l31vicrc3b5/" -Path C:\backup\back.back -Force
$newm = Get-SPuser -Web "http://win-l31vicrc3b5/" -Group "Team Site Members"
$newo = Get-SPuser -Web "http://win-l31vicrc3b5/" -Group "Team Site Owners"
$newv = Get-SPuser -Web "http://win-l31vicrc3b5/" -Group "Team Site Visitors"

foreach ($spuser in $newm){Remove-SPUser -Web "http://win-l31vicrc3b5/" -Identity $spuser -Group "Team Site Members" -confirm:$false}
foreach ($spuser in $newo){Remove-SPUser -Web "http://win-l31vicrc3b5/" -Identity $spuser -Group "Team Site Owners" -confirm:$false}
foreach ($spuser in $newv){Remove-SPUser -Web "http://win-l31vicrc3b5/" -Identity $spuser -Group "Team Site Visitors" -confirm:$false}

foreach ($spuser in $oldm){Set-SPUser -Web "http://win-l31vicrc3b5/" -Identity $spuser -Group "Team Site Members" -confirm:$false}
foreach ($spuser in $oldo){Set-SPUser -Web "http://win-l31vicrc3b5/" -Identity $spuser -Group "Team Site Owners" -confirm:$false}
foreach ($spuser in $oldv){Set-SPUser -Web "http://win-l31vicrc3b5/" -Identity $spuser -Group "Team Site Visitors" -confirm:$false}

write-host "Done"

Friday, 10 January 2014

AvePoint's DocAve 6 makes SharePoint administration better

Adding a user to large set of Document Libraries is now a snap

Over the years working with SharePoint some of the main user issues I get are these:

  1. Can I manage the columns of folders in dozens of sites around the Enterprise?
  2. Can I add a user to a large number of sites easily?
  3. Can I move a large number of document libraries from different site collections in to one site collection, or the other way around?
  4. Can I turn on versioning with a single click on every document library in the farm.
Using SharePoint Central Admin there are no ways to do this, you have to create complex PowerShell coding which is time consuming and frankly its hard to find PowerShell scripts.  Now I love PowerShell myself but it not really what you want your admins doing all day, you want them giving your users value.

That is why I am so excited about AvePoint's DocAve 6, which gives you a central admin UI, separate from SharePoint central Admin, that allows you to do these kinds of things, and many more.

Moving content from one site to another is easy with DocAve 6 rich UI
In my initial set of tests on DocAve 6 running against a SharePoint 2010 Foundation farm on a VM I was able to easily add and remove users from a large set of document libraries in one go, manage column of a large group of document libraries, and move content from a document library in one site collection to another.

This is really the right tool to be managing Central Admin for a large Enterprise estate.

A good case study, and one I see all the time, would be situation where each project got its own site collection with a template.  Now each site collection has edited its template so that the same information is encoded different between different projects.

With DocAve 6 its possible to clean up the document libraries, to make them more consistent and to clearly she what columns different teams have created.  You can also move all the document libraries in different site collections in to one managed site collection, making things more central.