Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Created February 13, 2019 21:34
Show Gist options
  • Save michaellwest/1f032892fb6c31864d43016c0b65c7a8 to your computer and use it in GitHub Desktop.
Save michaellwest/1f032892fb6c31864d43016c0b65c7a8 to your computer and use it in GitHub Desktop.
Generate an item url given an item and the sitecontext using Sitecore PowerShell Extensions.
function Get-ItemUrl {
param(
[item]$Item,
[Sitecore.Sites.SiteContext]$SiteContext
)
$result = New-UsingBlock(New-Object Sitecore.Sites.SiteContextSwitcher $siteContext) {
New-UsingBlock(New-Object Sitecore.Data.DatabaseSwitcher $item.Database) {
[Sitecore.Links.LinkManager]::GetItemUrl($item)
}
}
$result[0][0]
}
$siteContext = [Sitecore.Sites.SiteContext]::GetSite("website")
$item = Get-Item -Path "master:/content/home"
Get-ItemUrl -SiteContext $siteContext -Item $item
@aemstudy100
Copy link

We just want to break to Read :
ChallengeResponseUrl = $item.Fields["ChallengeResponseUrl"];
This shoud Rerturn : "/MC/Home/ChallengeErrorPage"
ChallengeResponseUrl Data Type is General Link Type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment