I'm working on some reports using Sitecore Powershell Extensions. One requirement is to provide the public URL for various Sitecore items. I'm thinking this isn't really possible via Link Manager because I don't have proper site context when running the report.
Is my thinking correct? Is there another non-hardcoded way to generate the URL in this scenario? Does the concept of context switching exist within PSE?
Probably important to note that this instance supports multiple sites so I can't assume a static domain for the URL.
UPDATE
After some Guidance from @Rirchard Seal and @Michael West below, here is what a function looks like to return a url:
function Get-UrlForItem($item) {
$linkUrl = ""
$siteContext = [Sitecore.Sites.SiteContext]::GetSite("website");
New-UsingBlock(New-Object -TypeName "Sitecore.Sites.SiteContextSwitcher" -ArgumentList $siteContext) {
$linkUrl = [Sitecore.Links.LinkManager]::GetItemUrl($item);
$linkUrl
}
}
Next up is to get the correct sitecontext for the item; right now I have it hard-coded to "website".
Thanks guys!