Last active
July 6, 2022 15:49
-
-
Save fluxdigital/a399d58359c73af89856c12e92182d94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Function used to find the CM Url | |
#> | |
function Get-CmUrl($item){ | |
$site = [Sitecore.Sites.SiteContext]::GetSite("website") | |
New-UsingBlock(New-Object -TypeName "Sitecore.Sites.SiteContextSwitcher" -ArgumentList $site) { | |
$urlOptions = [Sitecore.Links.LinkManager]::GetDefaultUrlOptions() | |
$urlOptions.AlwaysIncludeServerUrl = $True | |
$urlOptions.ShortenUrls = $True | |
$urlOptions.SiteResolving = $True; | |
$url = [Sitecore.Links.LinkManager]::GetItemUrl($item, $urlOptions) | |
return $url.TrimEnd('/') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment