3

I need to archive Sitecore items using Sitecore PowerShell. Any commnand that can be used to achieve this.?

2 Answers 2

3
# get item to archive
$item = Get-Item -Path '/sitecore/content/ITEM'

# see available archives for current database
[Sitecore.Data.Archiving.ArchiveManager]::GetArchives($item.Database)

# select archive that you want to use
$archive = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("archive",$item.Database)

# store an item in the archive
$archive.ArchiveItem($item)

# browse archive entries
$archive.GetEntries(0,10)

To get more useful function for Archive object see this class Sitecore.Data.Archiving.Archive

0
0

If you want to archive a particular item version then you need to write your logic like this.

# get item to archive and provide the version. Examle 3

$item = Get-Item -Path "master:" -Uri "sitecore://master/{6151ACBE-40C3-45D5-BCE8-5E939C461C12}?lang=en&ver=3"

[Sitecore.Data.Archiving.ArchiveManager]::GetArchives($item.Database)

$archive = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("archive", $item.Database)

$archive.ArchiveVersion($item)

$archive.GetEntries(0,10)

Now when you go to the Archive window, you will see the version you have archived

enter image description here

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.