0

how can I get path property of Sitecore item using PowerShell module?

5 Answers 5

4

You can get item properties using this command.

$itemID = "{8A87AC2B-210D-49F2-93FC-215918085418}" #Mention your Item ID

# Use Format-Table if you want to show results in the table view.
Get-Item -Path "master:" -ID "$itemID" | Format-Table -Property ID, Name, DisplayName, "Page Title", @{Label="Path"; Expression={$_.Paths.FullPath} }

# Use Show-ListView if you want to show result in a popup window 
Get-Item -Path "master:" -ID "$itemID" | Show-ListView -Property ID, Name, DisplayName, "Page Title", @{Label="Path"; Expression={$_.Paths.FullPath} }

The window will also give you the option to export. Like this.

enter image description here

Read this article for more operations.

https://doc.sitecorepowershell.com/working-with-items

2

You can get the path of Sitecore item through Powershell Script:-

Get-Item -Path "master:/sitecore/content/Home" | Show-ListView -Property `
    @{Label="ID"; Expression={$_.ID}},
    @{Label="Name"; Expression={$_.DisplayName}},
    @{Label="Path"; Expression={$_.Paths.Path}}

Update the path of Sitecore item "master:/sitecore/content/Home". To get the path of item, Click on the item in Sitecore Content tree and have a look at the Quick info tab and copy the Item path.

enter image description here

0

If you have the item as a variable and just want the Sitecore path, it is simple:

$item.Paths.Path
0
$item = Get-Item master:/content/home
Write-Host "Item path: " $item.FullPath    
 

It will give following output

Item path: /sitecore/content/Home

We can get item by Id and access all item property like this.

$item = Get-Item -Path  master: -ID {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}
Write-Host $item.Paths.Path

We can get more example here: https://gist.github.com/Adamsimsy/30dc60df837c1400e6fccd814b3dc752

0

In Sitecore, there are multiple ways to fetch the path of an item. Here are some common methods:

Using Item.Paths.Path Property:

This is the most straightforward way. You can access the Paths.Path property of the item object to get its path.

string itemPath = item.Paths.Path;

Using Item.Paths.FullPath Property:

Similar to Paths.Path, Paths.FullPath property returns the full path of the item, including the root node.

string fullPath = item.Paths.FullPath;

Using Item.Paths.GetPath(string itemPath):

You can use the Paths.GetPath method to get the path of an item based on a specific path format.

string path = item.Paths.GetPath("slash", true);

Using Item.Paths.GetAncestorOrSelfPaths():

This method returns an array of ancestor paths and the item's own path.

string[] paths = item.Paths.GetAncestorOrSelfPaths();

Using Item.Paths.GetParentPath():

This method returns the parent path of the item.

string parentPath = item.Paths.GetParentPath();

Using Item.Paths.LongID Property:

This returns the long ID of the item, which includes the full path.

string longId = item.Paths.LongID;

These methods provide flexibility depending on your specific use case. You can choose the one that best fits your requirements.

Your Answer

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