Product: PowerShell Universal
Version: 1.5.9
When using New-UDTable if I use the Data parameter the table shows up fine but if I change it to use LoadData it throws the Error e is null on the dashboard.
This code displays fine.
$Columns = @(
New-UDTableColumn -Property 'BackupFileName' -Title 'File Name'
New-UDTableColumn -Property 'FileSize' -Title 'Size/GB'
New-UDTableColumn -Property 'FileDate' - -Title 'Date'
New-UDTableColumn -Property 'RetentionYears' -Title 'Retention Years'
)
$SQL = "SELECT BackupFileName,FileSize,FileDate,RetentionYears FROM backupFile WHERE PendingDeletion = 1;"
$Data = Invoke-Sqlcmd -Query $sql -ServerInstance $DBServer -Username $SQLUsername -Password $SQLPassword -Database $DBName -EncryptConnection | ForEach-Object {
if (($_.FIleSize).ToString() -eq "")
{
$fSize = 0;
}
else {
$fsize = $_.FileSize
}
@{
BackupFileName = $_.BackupFileName;
FileSize = “{0:n2}”-f ($fSize/1gb);
FileDate = ($_.FileDate).tostring(“MM-dd-yyyy”);
RetentionYears = $_.RetentionYears
}
}
New-UDTable -Title "Pending Deletion" -Columns $Columns -Data $Data
But if I change to using a dynamic table it doesn’t work.
$Columns = @(
New-UDTableColumn -Property 'BackupFileName' -Title 'File Name'
New-UDTableColumn -Property 'FileSize' -Title 'Size/GB'
New-UDTableColumn -Property 'FileDate' - -Title 'Date'
New-UDTableColumn -Property 'RetentionYears' -Title 'Retention Years'
)
New-UDTable -Title "Pending Deletion" -Columns $Columns -LoadData {
$TableData = ConvertFrom-Json $Body
$SQL = "SELECT BackupFileName,FileSize,FileDate,RetentionYears FROM backupFile WHERE PendingDeletion = 1;"
$Data = Invoke-Sqlcmd -Query $sql -ServerInstance $DBServer -Username $SQLUsername -Password $SQLPassword -Database $DBName -EncryptConnection | ForEach-Object {
if (($_.FIleSize).ToString() -eq "")
{
$fSize = 0;
}
else {
$fsize = $_.FileSize
}
@{
BackupFileName = $_.BackupFileName;
FileSize = “{0:n2}”-f ($fSize/1gb);
FileDate = ($_.FileDate).tostring(“MM-dd-yyyy”);
RetentionYears = $_.RetentionYears
}
}
$Data | Out-UDTableData -Page $TableData.page -TotalCount $Data.Count -Properties $TableData.Properties
}
Then I see this.
Thank you,
Jeremy