Private/_PopulateGenericDataGrid.ps1

function _PopulateGenericDataGrid {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [ValidateSet('Software', 'Updates')]
        [string]$LookupType,

        [Parameter(Mandatory = $true)]
        [string]$Identity
    )
    $Object = @()
    switch ($LookupType) {
        # TODO if computer is not reachable, notify in the datagrid
        'Software' {
            $SoftwareListing = _GetInstalledSoftware -Identity $Identity | Sort-Object Name
            foreach ($Software in $SoftwareListing) {
                $Object += [PSCustomObject]@{
                    InstallDate      = $Software.InstallDate
                    Name             = $Software.Name
                    Version          = $Software.Version
                    UninstallCommand = $Software.UninstallCommand
                }
            }
            $GenericDataGrid.Title = 'Installed Software'
        }
        'Updates' {
            $Updates = _GetInstalledUpdates -Identity $Identity | Select-Object Title, Date, Description, Operation | Sort-Object Date -Descending
            foreach ($Update in $Updates) {
                $Object += [PSCustomObject]@{
                    Date        = $Update.Date
                    Title       = $Update.Title
                    Operation   = $Update.Operation
                    Description = $Update.Description
                }
            }
            $GenericDataGrid.Title = 'Installed Updates'
        }
        Default {
        }
    }

    $GenericDataGrid_DataGrid.ItemsSource = $Object
}