Made this for a larger project, simple but it works.
Install-Module -Name PS-Markdown
Out-MDTitle
- Outputs various sized titlesOut-MDCodeBlock
- Outputs codeblockOut-MDLink
- Outputs formatted linkOut-MDTable
- Converts a PSObject from another PS command to a markdown table. Converts every property in the object, so filter it first.Out-MDList
- Converts an array into a list, ordered and unordered supported.Out-MDText
- Outputs standard textOut-MDTableVertical
- Outputs a two column table with headers on the left and the value on the right.
Each command accepts the parameter -File
which points to the output file, if none is specified all commands output to the desktop. Each command appends to the markdown file, so they can be chained together in a script.
Set the default parameter value to stop you having to enter it for every command like so:
$PSDefaultParameterValues = @{"Out-MD*:File" = "C:\Output.md";}
PS C:\Users\Sam> Out-MDTitle -Title "hello" -Header h3
Outputs:
PS C:\Users\Sam> Out-MDTable (Get-NetAdapter | select Name,InterfaceAlias,Speed) -File 'C:\users\Sam\Desktop\example.md'
Outputs:
InterfaceAlias | Name | Speed |
---|---|---|
Wi-Fi | Wi-Fi | 173300000 |
vEthernet (Default Switch) | vEthernet (Default Switch) | 0 |
OpenVPN | OpenVPN | 10000000 |
Bluetooth Network Connection | Bluetooth Network Connection | 3000000 |
Ethernet | Ethernet | 0 |
PS C:\Users\Sam> Out-MDList -Items (Get-ComputerInfo).CsNetworkAdapters.Description -Ordered
Outputs:
- Intel(R) Ethernet Connection (6) I219-V
- Intel(R) Wireless-AC 9560 160MHz
- Bluetooth Device (Personal Area Network)
- Hyper-V Virtual Ethernet Adapter
- TAP-Win32 Adapter V9
Created this to create quick documentation like this:
$DHCP = Get-DhcpServerv4Scope
Foreach ($Scope in $DHCP) {
if ( $Scope.State -eq 'Active' ) { $enabled = '✔️' } else { $enabled = '❌' }
$leases = Get-DhcpServerv4Lease $Scope.scopeid.IPAddressToString
$reservations = Get-DhcpServerv4Reservation $Scope.scopeid.IPAddressToString
$ScopeData = [Ordered]@{
"Enabled" = $Enabled
"Scope ID" = $Scope.scopeid.IPAddressToString
"Subnet Mask" = $Scope.SubnetMask.IPAddressToString
"Lease Start" = $Scope.startrange.IPAddressToString
"Lease End" = $Scope.endrange.IPAddressToString
"Lease Count" = $leases.count
"Reservation Count" = $reservations.count
}
Out-MDTableVertical -InputObject $ScopeData -HeaderTitle $Scope.name
}
Out-MDTableVertical -InputObject $ScopeData -HeaderTitle $Scope.name
Which outputs something like this:
tk.internal | |
---|---|
Enabled | ✔️ |
Scope ID | 10.62.10.0 |
Subnet Mask | 255.255.255.0 |
Lease Start | 10.62.10.20 |
Lease End | 10.62.10.240 |
Lease Count | 176 |
Reservation Count | 10 |