|
| 1 | +--- |
| 2 | +external help file: Pansies-help.xml |
| 3 | +online version: |
| 4 | +schema: 2.0.0 |
| 5 | +--- |
| 6 | + |
| 7 | +# New-Hyperlink |
| 8 | + |
| 9 | +## SYNOPSIS |
| 10 | +Create a hyperlink with the specified Uri, and optionally using different text, background and foreground colors |
| 11 | + |
| 12 | +## SYNTAX |
| 13 | + |
| 14 | +``` |
| 15 | +New-Hyperlink [-Uri] <String> [[-Object] <Object>] [-Separator <Object>] [-BackgroundColor <RgbColor>] [-ForegroundColor <RgbColor>] [-LeaveColor] [-IgnoreEntities] [-Passthru] |
| 16 | +``` |
| 17 | + |
| 18 | +## DESCRIPTION |
| 19 | +Create a hyperlink with the specified Uri, using ANSI Virtual Terminal escape sequences. |
| 20 | +As with New-Text, there's full support for setting background and foreground colors, and rendering HTML-style entities. |
| 21 | + |
| 22 | +With -Passthru, returns the Text object, but normally outputs the text string with the Uri hyperlink embedded. |
| 23 | + |
| 24 | +## EXAMPLES |
| 25 | + |
| 26 | +### Example 1 |
| 27 | +``` |
| 28 | +PS C:\> New-Hyperlink https://PoshCode.org -ForegroundColor Green |
| 29 | +
|
| 30 | +`e[92m`e]8;;https://PoshCode.org`ahttps://PoshCode.org`e]8;;`a`e[39m |
| 31 | +``` |
| 32 | + |
| 33 | +Generates a hyperlink to https://PoshCode.org with the text https://PoshCode.org and a green foreground color. |
| 34 | + |
| 35 | +This use, without text (the `-Object` parameter) and with a highlight color, is the most compatible use, because if the terminal doesn't support links, at least the URL will be visible, and highlighted in color |
| 36 | + |
| 37 | +### Example 2 |
| 38 | +``` |
| 39 | +PS C:\> "Please visit $(New-Hyperlink https://PoshCode.org PoshCode)" |
| 40 | +
|
| 41 | +Please visit `e]8;;https://PoshCode.org`aPoshCode`e]8;;`a |
| 42 | +``` |
| 43 | + |
| 44 | +Generates a hyperlink to https://PoshCode.org with the text "PoshCode". You should be careful of this syntax, where you don't include the full URL in the display, because terminals which don't support hyperlinks (like the default Windows console) will not display the Url, nor any indication that it should be a link. |
| 45 | + |
| 46 | +## PARAMETERS |
| 47 | + |
| 48 | +### -Uri |
| 49 | +Specifies the Uri to link to. |
| 50 | + |
| 51 | +```yaml |
| 52 | +Type: String |
| 53 | +Parameter Sets: (All) |
| 54 | +Aliases: |
| 55 | + |
| 56 | +Required: True |
| 57 | +Position: 0 |
| 58 | +Default value: None |
| 59 | +Accept pipeline input: True (ByPropertyName, ByValue) |
| 60 | +Accept wildcard characters: False |
| 61 | +``` |
| 62 | +
|
| 63 | +### -BackgroundColor |
| 64 | +The background color. You may specify it as CSS hex "#RRGGBB" (or just "RRGGBB") or as an XTerm index "xt123" (or just "123") or as a ConsoleColor like "Red" or "DarkRed"... |
| 65 | +
|
| 66 | +```yaml |
| 67 | +Type: RgbColor |
| 68 | +Parameter Sets: (All) |
| 69 | +Aliases: Bg |
| 70 | + |
| 71 | +Required: False |
| 72 | +Position: Named |
| 73 | +Default value: None |
| 74 | +Accept pipeline input: False |
| 75 | +Accept wildcard characters: False |
| 76 | +``` |
| 77 | +
|
| 78 | +### -ForegroundColor |
| 79 | +The foreground color. You may specify it as CSS hex "#RRGGBB" (or just "RRGGBB") or as an XTerm index "xt123" (or just "123") or as a ConsoleColor like "Red" or "DarkRed"... |
| 80 | +
|
| 81 | +```yaml |
| 82 | +Type: RgbColor |
| 83 | +Parameter Sets: (All) |
| 84 | +Aliases: Fg |
| 85 | + |
| 86 | +Required: False |
| 87 | +Position: Named |
| 88 | +Default value: None |
| 89 | +Accept pipeline input: False |
| 90 | +Accept wildcard characters: False |
| 91 | +``` |
| 92 | +
|
| 93 | +### -IgnoreEntities |
| 94 | +If set, don't render the HTML Entities to characters (i.e. leave "♥" as "♥" instead of as "♥") |
| 95 | +
|
| 96 | +```yaml |
| 97 | +Type: SwitchParameter |
| 98 | +Parameter Sets: (All) |
| 99 | +Aliases: |
| 100 | + |
| 101 | +Required: False |
| 102 | +Position: Named |
| 103 | +Default value: None |
| 104 | +Accept pipeline input: False |
| 105 | +Accept wildcard characters: False |
| 106 | +``` |
| 107 | +
|
| 108 | +### -LeaveColor |
| 109 | +If set, don't clear the colors at the end of the output. |
| 110 | +
|
| 111 | +```yaml |
| 112 | +Type: SwitchParameter |
| 113 | +Parameter Sets: (All) |
| 114 | +Aliases: |
| 115 | + |
| 116 | +Required: False |
| 117 | +Position: Named |
| 118 | +Default value: None |
| 119 | +Accept pipeline input: False |
| 120 | +Accept wildcard characters: False |
| 121 | +``` |
| 122 | +
|
| 123 | +### -Object |
| 124 | +Specifies objects to display as the text of the link. |
| 125 | +
|
| 126 | +```yaml |
| 127 | +Type: Object |
| 128 | +Parameter Sets: (All) |
| 129 | +Aliases: |
| 130 | + |
| 131 | +Required: True |
| 132 | +Position: 0 |
| 133 | +Default value: None |
| 134 | +Accept pipeline input: True (ByValue, FromRemainingArguments) |
| 135 | +Accept wildcard characters: False |
| 136 | +``` |
| 137 | +
|
| 138 | +### -Separator |
| 139 | +Specifies a separator string to output between objects displayed on the console. |
| 140 | +
|
| 141 | +```yaml |
| 142 | +Type: Object |
| 143 | +Parameter Sets: (All) |
| 144 | +Aliases: |
| 145 | + |
| 146 | +Required: False |
| 147 | +Position: Named |
| 148 | +Default value: None |
| 149 | +Accept pipeline input: False |
| 150 | +Accept wildcard characters: False |
| 151 | +``` |
| 152 | +
|
| 153 | +### -Passthru |
| 154 | +If set, outputs a Text object, rather than simple string |
| 155 | +
|
| 156 | +```yaml |
| 157 | +Type: SwitchParameter |
| 158 | +Parameter Sets: (All) |
| 159 | +Aliases: |
| 160 | + |
| 161 | +Required: False |
| 162 | +Position: Named |
| 163 | +Default value: None |
| 164 | +Accept pipeline input: False |
| 165 | +Accept wildcard characters: False |
| 166 | +``` |
| 167 | +
|
| 168 | +## INPUTS |
| 169 | +
|
| 170 | +### System.Object |
| 171 | +
|
| 172 | +## OUTPUTS |
| 173 | +
|
| 174 | +### System.Object |
| 175 | +
|
| 176 | +## NOTES |
| 177 | +
|
| 178 | +## RELATED LINKS |
| 179 | +
|
0 commit comments