Dear all,
I am normally not the developer, but the technical farm consultant for SharePoint farms. Recently, one of the developers who are no longer available wrote a script to export and import site collections that also include nintex workflows. By the"ExportSite" function, I am stuck as it does not run this function. When it goes to run the rest, it generates an error that the filename doesn't exist. Can someone help me with the "ExportSite" function? See code:
#Add sharepoint pssnapin if it doesnt exist:
if ( (Get-PSSnapin -Name microsoft.sharepoint.powershell -EA "SilentlyContinue") -eq $null )
{
Add-PsSnapin microsoft.sharepoint.powershell
}
function ExportSite{
$filepath = $Title -replace '[\W]', ''
write-host "Preparing all Nintex workflows for export..." -ForegroundColor Green
$SourceSite = Get-SPSite -Identity $URL_Source
$webs = Get-SPWeb -Site $SourceSite -Limit All
foreach($web in $webs){
$SourcewebURL = $web.url
Write-Host "Preparing Nintex workflows on site $SourcewebURL" -ForegroundColor yellow
NWAdmin -o preparesiteforexport -SiteUrl $SourcewebURL
}
Write-Host "Exporting new site $title..." -ForegroundColor Green
Export-SPWeb -Identity $URL_Source -Path $ExportLocation\$filepath -IncludeUserSecurity -IncludeVersions All
Write-Host "Export of site $title finished. The export file are on location $ExportLocation" -ForegroundColor Green
}
function ImportSite{
$filepath = $Title -replace '[\W]', ''
Write-Host "Creating new site $title..." -ForegroundColor Green
New-SPSite -Url $URL_Target -OwnerAlias $OwnerAlias
Write-Host "Importing new site $title..." -ForegroundColor Green
Import-SPWeb -Identity $URL_Target -Path $ExportLocation\$filepath.cmp -ActivateSolutions -IncludeUserCustomAction All -IncludeUserSecurity -UpdateVersions Overwrite
$Target_Site = Get-SPSite -Identity $URL_Target
Write-Host "Restoring all Nintex workflows on all webs..." -ForegroundColor Green
$webs = Get-SPWeb -Site $TargetSite -Limit All
foreach($web in $webs){
$TargetwebURL = $web.url
Write-Host "Restoring Nintex workflows on site $TargetwebURL" -ForegroundColor yellow
NWAdmin.exe -o FixSiteAfterImport -siteUrl $TargetwebURL
}
Write-Host "Site $title is now available on $URL_Target" -ForegroundColor Green
}
$title = "Sitecollectionname"
$URL_Source
= "http://sitecollection"
$URL_Target
= "http://sitecollection2"
$ExportLocation
= "<Drive>:\export"
$OwnerAlias
= "DOMAIN\user"
#ExportSite
ImportSite
Thank you in advance,
Blue