-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy-Html.ps1
49 lines (42 loc) · 1023 Bytes
/
Copy-Html.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<#
.SYNOPSIS
Copies objects as an HTML table.
.INPUTS
System.Management.Automation.PSObject to be turned into a table row.
.LINK
Format-HtmlDataTable.ps1
.LINK
ConvertTo-SafeEntities.ps1
.LINK
Invoke-WindowsPowerShell.ps1
.EXAMPLE
Get-PSDrive |Copy-Html.ps1 Name,Description
Copies an HTML table with two columns to the clipboard as formatted text
that can be pasted into emails or other formatted documents.
#>
#Requires -Version 7
[CmdletBinding()][OutputType([void])] Param(
# Columns to include in the copied table.
[Parameter(Position=0)][array] $Property,
# The objects to turn into table rows.
[Parameter(ValueFromPipeline=$true)][psobject] $InputObject
)
Begin
{
$data = @()
}
Process
{
$data += $InputObject
}
End
{
$data |
Select-Object -Property $Property |
ConvertTo-Html -Fragment |
Format-HtmlDataTable.ps1 |
ConvertTo-SafeEntities.ps1 |
Out-String |
Set-Clipboard
Invoke-WindowsPowerShell.ps1 { Get-Clipboard |Set-Clipboard -AsHtml }
}