I am completely new to Sitecore PowerShell script making. I have a task where I need to get the media item url from the specific folder sitecore/media library/somefolderofimages.

Media Item URL that I am talking about is formatted like this: sitecore/media library/somefolderofimages/cat.png, for example, Content Editors can get the script which will export all of the media items URL from some folder to the CSV File.

If anybody has any tips, please make sure to comment and give me tips on how to do it. Thank you in advance!

1 Answer 1


You can create a PowerShell report by which content authors can execute whenever needed. There are other ways to achieve the same results like adding a Context menu or a button in ribbon etc...

        Lists all media items in a folder
$props = @{
    Title = "Lists all media items"
    Description = "Lists all Media items"
    OkButtonName = "Run Report"
    CancelButtonName = "Cancel"
    Parameters = @(
        @{ Name = "mediaRootItem"; Title = "Media Item Root Folder"; Editor = "droptree"; Source = "/sitecore/Media Library/" }
        @{ Title = "Note"; Value = "Select the root (folder) of the Media Items."; Editor = "info" }
$result = Read-Variable @props
if($result -ne "ok") {

function Get-MediaUrl($mediaitem) {
    $siteContext = [Sitecore.Sites.SiteContext]::GetSite("website");
    $result = New-UsingBlock(New-Object Sitecore.Sites.SiteContextSwitcher $siteContext) {

#Start Executing the Report
Get-ChildItem -Path master: -ID $mediaRootItem.ID -Recurse | Where-Object { $_.TemplateName -ne "Media Folder" } | Show-ListView

Reference: https://sitecorechat.slack.com/archives/C09THADMX/p1638803732147400

PowerShell Script Results Window

  • Thank you for answering. One question. Is this doing the part for the CSV export?
    – Samke11
    Dec 12, 2021 at 20:23
  • This script will open the results in a window where content authors can download it as Excel or any other formats. There is an option in Sitecore PowerShell to convert the result as Excel. Dec 15, 2021 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.