6

Trying to get the import operation executed using PowerShell code. Using below set of code lines the import operation is working fine, so all good till this point. But, I'm stuck when trying to get information related to imported items (updated, created items etc). Trying to get similar set of information what Content Porter tool generates after successful import operation, sample pasted below.

Did not find any relavant methods defined in these two classes ProcessInfo and ProcessSummary which can serve the purpose. Is there any specific way to get this info fetched using PS?

===================================================================

$uploadId = UploadPackageFromFile "D:\GT\package.zip"
$importInstruction = new-object Tridion.ContentManager.ImportExport.ImportInstruction
$impexp = GetImportExportServiceClient //Endpoint=http://localhost/webservices/ImportExportService201601.svc/basicHttp
$processId = $impexp.StartImport($uploadId, $importInstruction)

$varProcessInfo = $impexp.GetProcessInfo($processId)
$varProcessInfo.ProcessSummary 

====================================================================

Expected output pasted below:

Total items imported: 8
New items created: 1
Existing items updated: 6
Items partially imported: 0
Items failed: 0

New Created Items:
/webdav/030C%20Shared%20XYZ%20Content%20en_US/Building%20Blocks/Content/ABC/Biography/Mike.xml

Updated items:
/webdav/010%20Global%20Schemas/Building%20Blocks
/webdav/020C%20Global%20Content%20en_US/Building%20Blocks/Content
/webdav/030C%20Shared%20XYZ%20Content%20en_US
/webdav/030C%20Shared%20XYZ%20Content%20en_US/Building%20Blocks/Content/ABC
/webdav/030C%20Shared%20XYZ%20Content%20en_US/Building%20Blocks/Content/ABC/Biography
/webdav/030C%20Shared%20XYZ%20Content%20en_US/Building%20Blocks/Content/ABC/Biography/Peter.xml

2 Answers 2

6

The ProcessSummary class does have methods that provide information with regards to the items exported/imported. The screen shot below is the preview of the ProcessSummary class in Visual Studio.

enter image description here

To get the list of items that has been successfully imported use the DoneItems property. The Values contain the WebDAV URL of items. To determine if an imported item is newly created or updated, we would have to get the version info of the item. I was not able to find any methods/properties in the ImportExport namespace that determines this.

$processInfo = $impexp.GetProcessInfo($processId)
$doneItems = $processInfo.ProcessSummary.DoneItems;
foreach ($value in $doneItems.Values)
{
    write-host $value
}
2
  • Hi Sabarish, I do have tried this earlier, but this DoneItems value gives huge list of every item processed covering schema, TBB, CT , keywords, config components etc where in actual only one component modified. The description of ProcessSummary.DoneItems in API doc does match how its behaving. Commented Dec 31, 2019 at 23:51
  • 1
    @GulshanThakur, to prevent all dependencies of the modified component from being exported, you'd have to set the ExpandDependenciesOfTypes in the export instruction to an empty list like this: $exportInstruction.ExpandDependenciesOfTypes = New-Object 'System.Collections.Generic.List[Tridion.ContentManager.ImportExport.DependencyType]'. This will ensure only the modified component gets imported. Commented Jan 2, 2020 at 13:58
1

To print exactly the same output as content porter for updated items below PS code will work. You can use different values stored in ActionTypes as per your need to fetch list of updated, new created , skipped items etc.

$processedItems = $varProcessInfo.ProcessSummary.DoneItems.Values
foreach($type in $processedItems)
{  
  if($type.ActionTypes -eq 'Update')
  {   
    Write-Host $type.ItemId 
  }  
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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