Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (45 sloc) 1.76 KB
function Convert-ADSPowerShellForMarkdown {
Converts PowerShell code into valid Markdown URI Link text
Converts PowerShell code into valid Markdown URI Link Text
.PARAMETER inputstring
The endoded URL from the website
The text to show for the link
Will not output to screen but instead will set the clipboard
Convert-ADSPowerShellForMarkdown -inputstring "Set-Location C:\temp" -LinkText "CLick this link to set the location" -ToClipboard
Converts the PowerShell code Set-Location C:\temp so that it works with MarkDown, creates a link and sets it to the clipboard
June 2019 - Rob Sewell @SQLDbaWithBeard
[Parameter(Mandatory = $true)]
[string]$linktext = " LINK TEXT HERE ",
[Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null
$encodedstring = [System.Web.HttpUtility]::UrlEncode($inputstring)
$linkage = $encodedstring.Replace('+', ' ').Replace('%3a', ':').Replace('%5c', '%5c%5c').Replace('%22', '\u0022').Replace('%27', '\u0027').Replace('%0D%0A', '').Replace('%3b%0a','\u003B ').Replace('%0a','\u000A')
$outputstring = @"
<a href="command:workbench.action.terminal.sendSequence?%7B%22text%22%3A%22 $linkage \u000D %22%7D">$linktext</a>
if ($ToClipBoard) {
if (-not ($IsLinux -or $IsMacOS) ) {
$outputstring | Set-Clipboard
else {
Write-Warning "Set-Clipboard - Doesnt work on Linux - Outputting to screen"
else {
You can’t perform that action at this time.