1

We would like to pass the particular day and get the list of items changed on that day. Do we have any PowerShell script for that?

3 Answers 3

3

When you install the Sitecore PowerShell, there is already a similar script that performs the task you required. It is found at the following path: /sitecore/system/Modules/PowerShell/Script Library/SPE/Reporting/Content Reports/Reports/Content Audit/Items last updated.

When you run the script, it allows you

  • To pick up a date and time.
  • Pick whether the items should have been last updated before or after the specified date.

Below is a screenshot of the dialog that appears when you run the script

enter image description here

Note that you can customize the script to incorporate your additional requirements and as a best practice, it is better if you duplicate the script before making any changes.

2

Here is the simple PowerShell script, that you can use to filter by Date.

In the example below, I am trying to get all the items under Home Item by passing the item Id.

Get-ChildItem -Path "master" -ID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" -Recurse |  Where-Object { ($_.__Created).Date -eq [datetime]::Today} | Select-Object -Property Name, __Created

The Sitecore item field that I am using to compare is the __Created

So it will give me all the items that I have created today in the result like this.

enter image description here

You can extend it as per your needs.

Thanks

0
$startDate = [DateTime]"2023-1-01"
$endDate = [DateTime]"2023-1-12"

Get-ChildItem -Path "master" -ID "ITEM ID here" -Recurse |  Where-Object { ($_.__Updated).Date -ge $startDate -and ($_.__Updated).Date -lt $endDate} | Select-Object -Property Name, __Updated, @{Label="Path"; Expression={$_.Paths.FullPath}}

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.