How to escape hash symbol

Within a PowerShell script we collect TFS Build information values and post to octopus variables. Currently we are having a problem with a variable value that contains the “#” symbol, which is a valid character within a TFS Build url:

When this acquired variable is used within a custom expression, all characters from and after the hash symbol are removed.

Example custom expression:
#{Octopus.Action[Get TFS Build Details].Output.BuildUrl}

Resulting output:

Expected output:

Question: How to escape the hash symbol when using it within a custom expression?

fyi - escaping the character up-front with %23 won’t suffice, TFS Server doesn’t like it:
A potentially dangerous Request.Path value was detected from the client (:).

I was wrong - I do not need to escape this character after all! Because the hashtag represents a fragment identifier, it will not display within a hyperlink, while it actually exists. I dubiously thought the full Url value was being ignored because of the hashtag - I was wrong - all is good.

Hi Sean,

Glad to hear you figured this out. As always do not hesitate to contact us :slight_smile: