| external help file | PSScriptTools-help.xml |
|---|---|
| Module Name | PSScriptTools |
| online version | http://bit.ly/31Nn21e |
| schema | 2.0.0 |
Convert pipeline output to a markdown document.
ConvertTo-Markdown [[-Inputobject] <Object>] [-Title <String>] [-PreContent <String[]>]
[-PostContent <String[]>] [-Width <Int32>] [-AsTable] [<CommonParameters>]This command is designed to accept pipelined output and create a markdown document. The pipeline output will formatted as a text block or you can specify a table. You can optionally define a title, content to appear before the output and content to appear after the output.
The command does not create a text file. You need to pipe results from this command to a cmdlet like Out-File or Set-Content. See examples.
PS C:\> Get-Service Bits,Winrm | Convertto-Markdown -title "Service Check" -precontent "## $($env:computername)"
# Service Check
## THINK51
\`\`\`text
Status Name DisplayName
------ ---- -----------
Running Bits Background Intelligent Transfer Ser...
Running Winrm Windows Remote Management (WS-Manag...
\`\`\`Create markdown output from a Get-Service command.
PS C:\> Get-Service Bits,Winrm | Convertto-Markdown -title "Service Check" -precontent "## $($env:computername)" -postcontent "_report $(Get-Date)_" | Out-File c:\work\svc.mdRe-run the previous command and save output to a file.
PS C:\> $computers = "srv1","srv2","srv4"
PS C:\> $Title = "System Report"
PS C:\> $footer = "_report run $(Get-Date) by $($env:USERDOMAIN)\$($env:USERNAME)_"
PS C:\> $sb = {
>> $os = get-ciminstance -classname win32_operatingsystem -property caption,lastbootUptime
>> \[PSCustomObject\]@{
>> PSVersion = $PSVersionTable.PSVersion
>> OS = $os.caption
>> Uptime = (Get-Date) - $os.lastbootUpTime
>> SizeFreeGB = (Get-Volume -DriveLetter C).SizeRemaining /1GB
>> }
>> }
PS C:\> $out = Convertto-Markdown -title $Title
PS C:\> foreach ($computer in $computers) {
>> $out+= Invoke-command -scriptblock $sb -ComputerName $computer -HideComputerName |
>> Select-Object -Property * -ExcludeProperty RunspaceID |
>> ConvertTo-Markdown -PreContent "## $($computer.toUpper())"
>> }
PS C:\>$out += ConvertTo-Markdown -PostContent $footer
PS C:\>$out | set-content c:\work\report.mdHere is an example that create a series of markdown fragments for each computer and at the end creates a markdown document.
Typically the results of a PowerShell command or expression.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseSpecify a top level title. You do not need to include any markdown.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseEnter whatever content you want to appear before converted input. You can use whatever markdown you wish.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseEnter whatever content you want to appear after converted input. You can use whatever markdown you wish.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecify the document width. Depending on what you intend to do with the markdown from this command you may want to adjust this value.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 80
Accept pipeline input: False
Accept wildcard characters: FalseFormat the incoming data as a markdown table. This works best with similar content such as the result of running a PowerShell command.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Learn more about PowerShell: https://jdhitsolutions.com/blog/essential-powershell-resources/