Posts

Showing posts from November, 2018

Sitecore Powershell Script to find items with an empty field

Image
I came across the necessity to build a report based on some parameters. The end goal of the script is to retrieve items that have been edited during a certain time period and that have a certain field empty.

The UI will end up looking like this:


As it can be seen in the screenshot above, the user will be able to set 4 parameters:

Root - Which is going to be the parent node we will be analyzing From Date - The start updated dateTo Date - The end updated datePages Only - When checked, only items having a layout will be present in the report Now that we know what the parameters are, let's get into the code. First we need to create the UI, to do this we use the following: 
$fromdate = $null $todate = $null $pagesOnly = $false $database = "master" $root = Get-Item -Path "$($database):\content\Home" $settings = @{ Title = "Empty Field Report" Width = "600" Height = "600" OkButtonName = "Run" Cancel…