Read and export Sitecore item fields using powershell.

 $database = "master"

$root = Get-Item -Path (@{$true="$($database):\content\ExactSciences\Websites\Cologuard\Cologuard\Settings\Redirects";

false="$($database):\content\ExactSciences\Websites\Cologuard\Cologuard\Settings\Redirects"}[(Test-Path -Path "$($database):\content\ExactSciences\Websites\Cologuard\Cologuard\Settings\Redirects")])

$props = @{

    Parameters = @(

        @{Name="root"; Title="Choose the report root"; Tooltip="Only items from this root will be returned."; })

    Title = "Export Lists all content items and media items"

    Description = "Choose the criteria for the report."

    Width = 550

    Height = 300

    ShowHints = $true

}

$result = Read-Variable @props

if($result -eq "cancel") {

    exit

}

$templateId="{F4FB6125-F113-4373-8AA2-4648C2C1960E}"

$items = Get-ChildItem -Path $root.ProviderPath -Recurse | Where-Object { $_.TemplateId -eq $templateId }

if($items.Count -eq 0) {

    Show-Alert "There are no content items"

} else {

    $props = @{

        Title = "Content Audit Sheet"

        InfoTitle = "Export Content Items and Images List"

        InfoDescription = "Export Lists with the help of CSV option"

        PageSize = 50

    }    

$items | 

        Show-ListView @props -Property @{Label="GUID"; Expression={$_.ID} },

@{Label="Name"; Expression={$_.DisplayName} },

@{Label="Type"; Expression= {$_.Fields["RedirectType"]}}, 

@{Label="Path"; Expression={[System.Web.HttpUtility]::UrlDecode($_.Fields["UrlMapping"])} },

@{Label="Template"; Expression= {$_.TemplateName }}             

}

Comments