Get-ArchiveItem
Retrieves a list of items found in the specified archive.

Syntax

1
Get-ArchiveItem -Archive <Archive>
2
Get-ArchiveItem -Archive <Archive> [-ItemId <ID>]
3
Get-ArchiveItem -Archive <Archive> [-Identity <AccountIdentity>]
Copied!

Detailed Description

The Get-ArchiveItem command returns items found in the "archive" and "recyclebin" archives.
© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Archive <Archive>

Specifies the archive to use when determining which ArchiveEntry items to process. Use Get-Archive to find the appropriate archive.
Aliases
Text
Required?
true
Position?
named
Default Value
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-ItemId <ID>

Specifies the ID for the original item that should be processed. This is NOT the ArchivalId.
Aliases
Text
Required?
false
Position?
named
Default Value
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-Identity <AccountIdentity>

Specifies the user responsible for moving the item to the archive.
Aliases
Text
Required?
false
Position?
named
Default Value
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

Inputs

None.

Outputs

The output type is the type of the objects that the cmdlet emits.
  • Sitecore.Data.Archiving.ArchiveEntry

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

The following returns all items found in the specified archive.
1
$database = Get-Database -Name "master"
2
$archiveName = "recyclebin"
3
$archive = Get-Archive -Database $database -Name $archiveName
4
Get-ArchiveItem -Archive $archive
Copied!

EXAMPLE 2

The following returns items matching the ItemId found in the specified archive.
1
$database = Get-Database -Name "master"
2
$archiveName = "recyclebin"
3
$archive = Get-Archive -Database $database -Name $archiveName
4
Get-ArchiveItem -Archive $archive -ItemId "{1BB32980-66B4-4ADA-9170-10A9D3336613}"
Copied!

EXAMPLE 3

The following returns items moved to the recycle bin by the user found in the specified archive.
1
$database = Get-Database -Name "master"
2
$archiveName = "recyclebin"
3
$archive = Get-Archive -Database $database -Name $archiveName
4
Get-ArchiveItem -Archive $archive -Identity "sitecore\admin"
Copied!

EXAMPLE 4

The following demonstrates changing the archive date on an item followed by retrieving the archived item.
1
$item = Get-Item -Path "master:" -ID "{1BB32980-66B4-4ADA-9170-10A9D3336613}"
2
$date = $item[[Sitecore.FieldIDs]::ArchiveDate]
3
$serverTime = [Sitecore.DateUtil]::IsoDateToServerTimeIsoDate($date)
4
$serverTimeDateTime = [Sitecore.DateUtil]::IsoDateToDateTime($serverTime, [datetime]::MinValue)
5
6
# Here you could add more time to the $serverTimeDateTime
7
8
$utcTimeDateTime = [Sitecore.DateUtil]::ToUniversalTime($serverTimeDateTime)
9
$isoTime = [Sitecore.DateUtil]::ToIsoDate($utcTimeDateTime)
10
11
$item.Editing.BeginEdit()
12
$item[[Sitecore.FieldIDs]::ArchiveDate] = $isoTime
13
$item.Editing.EndEdit()
14
15
# Some time after the date has passed
16
$database = Get-Database -Name "master"
17
$archiveName = "archive"
18
$archive = Get-Archive -Database $database -Name $archiveName
19
Get-ArchiveItem -Archive $archive -ItemId "{1BB32980-66B4-4ADA-9170-10A9D3336613}"
Copied!

Related Topics