Is there are way to run the Export-SPSite command without exporting sub-sites? I just want to export the parent site from a web app, but there are about 120 sub-sites in the site collection that I want to skip.


I think you mean Export-SPWeb: http://technet.microsoft.com/en-us/library/ff607895.aspx. It does not have a switch for excluding subsites.

The other options for export are the SPExport class in the Microsoft.SharePoint.Deployment, but unfortunately the SPExportSettings object doesn't have a way to exclude subsites...not sure why it doesn't when the Sites Web Services ExportWeb method does support it...

The ExportWeb method of the Sites Web Services has a parameter to IncludeSubWebs: http://msdn.microsoft.com/en-us/library/websvcsites.sites.exportweb.aspx. And it works (...just set it to False)...we tried all these different methods when we were StoragePoint testing to determine how the OOB capabilities handled remoted BLOBS.

| improve this answer | |
  • +1 this is exactly what I needed to hear. Thanks Rob! – Mike May 30 '14 at 16:06

The SPExportSettings of the SPExport object has an obscure ExportObjects property that is used to control if subwebs are included or not. Adding SPIncudeDecendants.Content will exlude subwebs. See for example: http://www.codeproject.com/Articles/72521/Using-SPExport-and-SPImport-Part-1

It seems that the Export-SPWeb cmdlet does not expose ExportObjects, still you can use the object model directly in powershell like this: http://shannonbray.wordpress.com/2010/06/26/moving-sharepoint-2007-sites-to-another-environment-with-powershell/

| improve this answer | |

Export-SPWeb does not have an option to export only one website excluding children sites. Anyway, is possible to call directly the sharepoint library to obtain the result. This is the script.

$srcurl = "https://prova.webapp.it/sites/coll1/subsite"
$path = "d:\temp\folder"

$SPExport = New-Object Microsoft.SharePoint.Deployment.SPExport
$settings = $SPExport.Settings
$settings.SiteUrl= $srcurl
$settings.BaseFilename = "Manifest.xml"
$settings.FileCompression = $false
$settings.FileLocation = $path
$settings.CommandLineVerbose = $false
$settings.OverwriteExistingDataFile = $false
$settings.ExcludeDependencies = $true
$settings.ExportMethod = [Microsoft.SharePoint.Deployment.SPExportMethodType]"ExportAll"
$settings.LogFilePath = "$path\export-with-spexport.log"
$settings.IncludeVersions = [Microsoft.SharePoint.Deployment.SPIncludeVersions]"All"
$settings.IncludeSecurity = [Microsoft.SharePoint.Deployment.SPIncludeSecurity]"All"

$expWeb = New-Object Microsoft.SharePoint.Deployment.SPExportObject
$expWeb.Url = $srcurl
$expWeb.Type = [Microsoft.SharePoint.Deployment.SPDeploymentObjectType]"Web"
$expWeb.IncludeDescendants = [Microsoft.SharePoint.Deployment.SPIncludeDescendants]"Content"
$expWeb.ExcludeChildren = $True


In this case all are exported all the versions and all the security. Limited to the website and excluding the children sites. The result will be placed in a non-compressed folder. To import in another site you can use the usual import-spweb after having created the blank destination site.

$web = get-spweb $srcurl
$template = $web.WebTemplate+"#"+$web.configuration
$desturl = "https://prova.webapp.it/sites/coll2/destwebx"
$path = "d:\temp\folder"    
new-spweb $desturl -Language 1040 -Template $template
import-spweb -identity $desturl -path $path -nofilecompression -includeusersecurity

Tested with SP2013 and SP2016 but I think works also in SP2010.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.