Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am running following powershell to import a list into my own site collection so i can test some piece (like retain modified date from a export), etc. I keep getting The file Lists/Sales Status cannot be imported because its parent /sites/agentTest/sales does not exists.

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges( 
{
$SiteUrl = "http://intranet.company.com/sites/agentTest"
$site = new-object Microsoft.SharePoint.SPSite($SiteUrl)

$web = $site.OpenWeb("sales")
$cmpLocation = "c:\\"
$cmpFile = "testlist.cmp" 
$import = new-object Microsoft.SharePoint.Deployment.SPImport 

#$settings = New-Object Microsoft.SharePoint.Deployment.SPImportSettings
$settings = $import.Settings
#$settings.SiteUrl = $Siteurl
$settings.SiteUrl = $web.Url
$settings.WebUrl = $web.Url
$settings.FileLocation = $cmpLocation
$settings.BaseFileName = $cmpFile
$settings.FileCompression = $true
$settings.RetainObjectIdentity = $true
$settings.UserInfoDateTime = [Microsoft.SharePoint.Deployment.SPImportUserInfoDateTimeOption]::ImportAll

#$import = new-object Microsoft.SharePoint.Deployment.SPImport($settings)
#$import.Settings = $settings
$import.Run()
})
share|improve this question
    
Wish I had some patience today as it's Friday evening and Boss wants the list restored asap. –  M. Todd Jul 20 '12 at 21:42
    
Not sure if this is related but I'm pretty sure you don't have to escape the \ in powershell (i.e. 'C:\\") –  Dave Wise Jul 20 '12 at 22:20
    
Also, if you use ISE, you can step through this line by line and see exactly where the error is coming from –  Dave Wise Jul 20 '12 at 22:21
1  
I was able to your PS and it worked. Change the url to another url to test. OR check your permission. –  Bill Baer Jul 20 '12 at 22:33
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.