Skip to content

Instantly share code, notes, and snippets.

@wsmelton
Created July 1, 2017 02:51
Show Gist options
  • Save wsmelton/718740f58b141a6a23241fecab4641c1 to your computer and use it in GitHub Desktop.
Save wsmelton/718740f58b141a6a23241fecab4641c1 to your computer and use it in GitHub Desktop.
Generate Content View utilizing VS Code from an input object
<#
.SYNOPISIS
Generate an HTML view that will open in an editor for VS Code
.NOTES
Add this to your Microsoft.VSCode_profile.ps1 file
.EXAMPLE
$results = Get-DbaSpConfigure -SqlInstance manatarms
Out-CodeView $results
#>
function Out-CodeView {
param([object]$InputObject, [int]$colNum = 1)
$v = New-VSCodeHtmlContentView -Title "Untitled $(Get-Random)" -ShowInColumn $colNum
$c = ($InputObject | ConvertTo-Html -Fragment) -join "`r`n"
Set-VSCodeHtmlContentView -HtmlContentView $v -HtmlBodyContent $c
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment