6

I am trying to backup a list and am getting the error

Export-SPWeb : Cannot find an SPWeb object with Id or Url

. I'm guessing this is related to the space in the list name. I've tried this command a million different ways, so what is the best way to do this? I've read about the double quotes, but can't make it work.

Export-SPWeb -Identity https://servername/path -Path C:\backup.cmp -ItemUrl "/Lists/Mortgage Referrals"

  • i am sure you have access to central admin, try to export from central admin – Waqas Sarwar MVP Feb 25 '16 at 19:04
  • I'm guessing because your -ItemUrl isn't valid. Export-SPWeb -ItemUrl states "Specifies the URL of the Web application, GUID, or object to be exported. The type must be a valid URL; for example, server_name." – Eric Alexander Feb 25 '16 at 19:08
9

You command should be look like this

Export-SPWeb -Identity https://servername/path -Path C:\backup.cmp -ItemUrl "Lists/Mortgage Referrals"
  • in identity complete URL of Site collection.
  • at ItemURL you should not use '/' if it is on root of site collection.
  • That was it! After the -ItemUrl I had: "/lists/etc" instead of your "lists/etc". Can't believe I missed it. Thanks! – Dude Feb 25 '16 at 20:49
  • i am sure, you will marked it answer n vote up as well.:) – Waqas Sarwar MVP Feb 25 '16 at 20:53
  • Are you sure that it needs / if not at root of site collection? I thought ItemUrl was web-relative (I could be well wrong) – James Love Feb 26 '16 at 6:54
  • @JamesLove Citing Brian from MS PFE team (link is up there in my answer): basically under the covers the Export-SPWeb cmdlet will call SPWeb.GetList(), but prior to calling that function it will prepend the SPWeb.ServerRelativeUrl and an extra “/” if the string in ItemUrl does not have a leading “/”. In short, to be safe if you always set the ItemUrl parameter to the server relative url and then path to the list, it should always work regardless of web location – Aziz Kabyshev Feb 26 '16 at 11:03
1

General syntax is this:

Export-SPWeb -Identity "http://site" -Path D:\list.cmp -ItemUrl "/Lists/{ListUrl}"

But what you need to put in {List} part of -ItemUrl argument is a URL, not a list title. To find it, look at URL of any view of your list, 'Mortgage Referrals'. It looks like http://site/Lists/{ListUrl}/view.aspx. That's it. Copy that part to Export-SPWeb.

Get it in powershell:

($w.Lists["Mortgage Referrals"].DefaultViewUrl -split "/")[2]
# this will return {ListUrl} part

So, combined two-liner looks like this:

$itemUrl = (((Get-SPWeb "http://site").Lists["Mortgage Referrals"].DefaultViewUrl -split "/") | select -first 3) -join "/"
Export-SPWeb -Identity "http://site" -Path D:\list.cmp -ItemUrl $itemUrl

Update: oh, just one more thing here. Export-SPWeb differs when executed on root sites and non-root sites. Take a look at http://blogs.msdn.com/b/briangre/archive/2014/03/18/export-spweb-syntax-changes-between-root-site-and-sub-sites.aspx

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.