none
Export-SPWeb with GUID doesnt'work RRS feed

  • Question

  • Hello,

    I got a site collection corrupted and I would like to export this site coll to Import it again.How can I perform an Export-SPWeb with the GUID and not the URL ?

    This one doesn't work:

    $web = get-spweb -Identity "http://myHost:13105/sites/test"

    $correctId = $web.ID

    Export-SPWeb -Identity $correctId -Path "D:\backupTest.cmp"

    This one is working:

    Export-SPWeb -Identity "http://myHost:13105/sites/test" -Path "D:\backupTest.cmp"

    And I would like to have it by GUID

    THanks



    • Edited by MS-Cbu Wednesday, April 25, 2012 9:37 AM
    Wednesday, April 25, 2012 8:55 AM

Answers

  • Hi, Could you execute the following:

    $id = Get-SPSite http://myhost:13105/sites/test | select ID
    
    $newid = ($id.ID).ToString()
    
    $webs = (Get-SPSite $newid).Allwebs
    foreach($web in $webs)
    {
    if($web.id -eq "954F8E97-0950-4645-9B0C-119F8AC08C67")
    {
    Export-SPWeb $web -Path "D:\install\test.cmp"
    }
    }

    Kind regards,

    Nico Martens - MCTS, MCITP
    SharePoint 2010 Infrastructure Consultant
    Blog: SharePoint Related
    E-mail: Nico Martens

    Wednesday, April 25, 2012 12:39 PM

All replies

  • Hi MS-Cbu,

    I have been checking this for the past hour, the only thing I can come up with is that if you use the ID as identity parameter, it does not know what SPSite object belongs to the ID.

    The error it is giving is:

    Cannot find an SPWeb object with Id or Url: <web id> and Site Id: Empty or Null.

    Digging some more revealed more.

    Export-SPWeb -Identity parameter:  The type must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; a valid name of Microsoft SharePoint Foundation 2010 Web site (for example, MySPSite1); or an instance of a valid SPWeb object.

    Get-SPWeb -Identity parameter: Specifies the name or full or partial URL of the subsite. If you use a relative path, you must specify the
    Site parameter. In this scenario, the Site parameter does not exist.

    My theory is that Export-SPWeb first tries to use Get-SPWeb to confirm that the SPWeb object is correct, and when you enter the GUID, it is trying to get the Site that is connected to this SPWeb object, but it fails.

    Now for your problem: Why do you want to use the ID for the Export-SPWeb cmdlet? Maybe we can find a way around this.


    Kind regards,

    Nico Martens - MCTS, MCITP
    SharePoint 2010 Infrastructure Consultant
    Blog: SharePoint Related
    E-mail: Nico Martens

    Wednesday, April 25, 2012 12:14 PM
  • I would like to use the GUID because my Site Collection is corrupted, no URL are mapped on.

    So I only can access to my Site Coll with this GUID.

    You see what I mean ?

    Thanks

    Wednesday, April 25, 2012 12:17 PM
  • Does this work?

    Get-SPSite | fl url, ID

    If it does, you can use the following cmdlets:

    $webs = (Get-SPSite "Site coll ID").Allwebs
    foreach($web in $webs)
    {
    if($web.id -eq "Web ID")
    {
    Export-SPWeb $web -Path "D:\install\test.cmp"
    }
    }
    I just ran this script for my test environment, and it exported the web.

    Kind regards,

    Nico Martens - MCTS, MCITP
    SharePoint 2010 Infrastructure Consultant
    Blog: SharePoint Related
    E-mail: Nico Martens

    Wednesday, April 25, 2012 12:28 PM
  • PS C:\Users\Administrator> $webs = (Get-SPSite "954F8E97-0950-4645-9B0C-119F8AC0
    8C67").Allwebs
    Get-SPSite : Cannot find an SPSite object with Id or Url: 954f8e97-0950-4645-9b
    0c-119f8ac08c67.
    At line:1 char:20
    + $webs = (Get-SPSite <<<<  "954F8E97-0950-4645-9B0C-119F8AC08C67").Allwebs
        + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:
       SPCmdletGetSite) [Get-SPSite], SPCmdletPipeBindException
        + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

    voila..

    Any idea ?

    • Edited by MS-Cbu Wednesday, April 25, 2012 12:33 PM
    Wednesday, April 25, 2012 12:33 PM
  • Hi, Could you execute the following:

    $id = Get-SPSite http://myhost:13105/sites/test | select ID
    
    $newid = ($id.ID).ToString()
    
    $webs = (Get-SPSite $newid).Allwebs
    foreach($web in $webs)
    {
    if($web.id -eq "954F8E97-0950-4645-9B0C-119F8AC08C67")
    {
    Export-SPWeb $web -Path "D:\install\test.cmp"
    }
    }

    Kind regards,

    Nico Martens - MCTS, MCITP
    SharePoint 2010 Infrastructure Consultant
    Blog: SharePoint Related
    E-mail: Nico Martens

    Wednesday, April 25, 2012 12:39 PM