Skip to content

Instantly share code, notes, and snippets.

@trackd
Created January 22, 2024 14:04
Show Gist options
  • Save trackd/bde8266b15e50c71246696517f04ca48 to your computer and use it in GitHub Desktop.
Save trackd/bde8266b15e50c71246696517f04ca48 to your computer and use it in GitHub Desktop.
function Get-TableData {
<#
ls | ft | Get-TableData
.NOTES
https://gist.github.com/Jaykul/9999be71ee68f3036dc2529c451729f4
#>
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
$FormatStartData
)
process {
if (-Not $properties) {
if ($_.GetType().Name -eq "FormatStartData") {
$properties = [ordered]@{}
$y = 0
@($FormatStartData.shapeInfo.tableColumnInfoList).Where{ $_ }.ForEach{
$Name = $_.Label ? $_.Label : $_.propertyName
$properties[$Name] = @{
Label = $Name
Width = $_.width
Alignment = $_.alignment
i = $y
}
$y++
}
$properties
}
}
if ($_.GetType().Name -eq "FormatEntryData") {
$i = 0
$row = @($FormatStartData.FormatEntryInfo.FormatPropertyFieldList).Where{ $_ }.ForEach{
[PSCustomObject]@{
alignment = $_.alignment
Value = $_.propertyValue
i = $i
}
$i++
}
$row
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment