0

I have a structure as follow:

My Site (Root site)

  1. Client 1

    Division 1

         >  Site 101
         >  Site 102
    

    Division 2

  2. Client 2

    Division 1

    Division 2

In the above structure, how do I move "Site 101" from:

Client 1 >> Division 1

TO

Client 2 >> Division 2

How can this be achieved programmatically? (i.e. c-sharp)


Possible duplicate of SharePoint Online - Move Site and subsites into another site – Atish Dipongkor 16 mins ago

---->

It isn't duplicate as my question is to move the child subsites "PROGRAMMATICALLY"

"using powershell? or using c# etc? – Waqas Sarwar MCSE"

-- I am leaning more towards c#...possibly by using API's CSOM etc.

  • It doesn't solve my problem – SP USER Sep 19 '16 at 13:33
  • using powershell? or using c# etc? – Waqas Sarwar MVP Sep 19 '16 at 14:07
0

Use PowerShell. Found on google.

add SharePoint snapin

Add-PSSnapin Microsoft.SharePoint.PowerShell –ea SilentlyContinue

set variables - FYI exportfolder will throw an error if folder is already created.

$exportfolder = "E:\SiteExports\NAME" $exportfile = "\NAME.cmp" $exportsite = "http://client1/divison1/site 101" $exportlocation = $exportfolder+$exportfile $importlocation = "http://client2/division2/site 101"

get export site's template

$web = Get-SPWeb $exportsite $webTemp = $web.WebTemplate $webTempID = $web.Configuration $webTemplate = "$webTemp#$webTempID" $web.Dispose()

create export folder

$null = New-Item $exportfolder -type directory

export site

Export-SPWeb $exportsite –Path $exportlocation -IncludeUserSecurity -IncludeVersions 4 Write-host "$exportsite has been exported to $exportlocation"

create new site ready for import

$null = New-SPWeb $importlocation -Template "$webTemplate" Write-host "$importlocation created ready for import"

import site

Import-SPWeb $importlocation –Path $exportlocation -IncludeUserSecurity –UpdateVersions 2 Write-host "$exportsite has been imported to $importlocation" -foregroundcolor "Green"

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.