Visual Upgrade to SP2013
Add-PSSnapin Microsoft.Sharepoint.Powershell -ErrorAction SilentlyContinue
$ErrorActionPreference = "Continue"
$now = Get-Date
$xmlFilePath = "C:\yourOutputFile.txt"; #ouput from stsadm -o enumsites
$csvLogFileName = "VisualUpgraded.txt"
$csvLogSkipped = "VisualUpgradeSkipped.txt"
function Heading($inputText)
{
$color = "Green"
write-host "=============================================" -ForegroundColor $color
Write-Host $inputText -ForegroundColor $color
write-host "=============================================" -ForegroundColor $color
}
#Read Xml file
if(-not(Test-Path $xmlFilePath))
{
"File '{0}' not found." -f $xmlFilePath
break;
}
$xml = [xml](Get-content $xmlFilePath)
$xSites = $xml.SelectNodes("Sites/Site")
$count = $xSites.Count.ToString();
#Add header only if file doesnt exist, else continue to existing file
if(-not(Test-Path $csvLogFileName))
{
"DatabaseName,StorageUsedMB,SiteUrl,SqlServerName,Time" > $csvLogFileName
}
if(-not(Test-Path $csvLogSkipped))
{
"Message,SiteUrl,Time" > $csvLogSkipped
}
"=======================================================" >> $csvLogFileName
"=======================================================" >> $csvLogSkipped
$i = 0
$startIndex = 0 #$xSites.count #, use 0 if you want to start from beginning (and update ($i -eq $startIndex) sign to -eq, -gt ... in conndition)
#loop in case of starting from the middle in crash scenario
foreach($xSite in $xSites)
{
if ($xSite.Url -eq "https://yourStartSiteCollection")
{
Write-Host "Start found: " $xSite.Url
$startIndex = $i
}
if($i -ge $startIndex) #use -eq here for only one collection
{
$siteUrl = $xSite.Url
$heading = ("{0}/{1} {2}" -f ($i+1), $count, $siteUrl).ToString()
Heading $heading
$existingSite = Get-SPSite -limit All | where {$_.Name -match $siteUrl}
if($existingSite -eq $null)
{
"Site '{0}' doesn't exist." -f $siteUrl
("Doesn't exist, {0},{1}" -f $siteUrl, (Get-Date)) >> $csvLogSkipped
}
else
{
$result = Test-SPSite $siteUrl
if ($result.FailedErrorCount -ne 0)
{
("Error, {0},{1}" -f $siteUrl, (Get-Date)) >> $csvLogSkipped
}
else
{
Upgrade-SPSite $siteUrl -VersionUpgrade
("{0},{1},{2},{3}" -f $xSite.ContentDatabase, $xSite.StorageUsedMB,$siteUrl,(Get-Date)) >> $csvLogFileName
}
}
}
#Read-Host "Press any key to continue..." #use his stop to check before proceeding
$i++
}
$duration = (Get-Date) - $now
"{0}h:{1}min:{2}s" -f $duration.Hours, $duration.Minutes, $duration.Seconds