Archive/_GetWUGDevicesOLD.ps1

function _GetWUGDevicesOLD {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $DeviceGroup
    )

    $Script:Devices = Get-WUGDevices -GroupID ($DeviceGroups | Where-Object name -EQ $WhatsUpGold_DeviceGroupComboBox.Text).id | Select-Object @{Name = 'Host Name'; Expression = { $_.hostName } }, @{Name = 'IP Address'; Expression = { $_.networkAddress } }, @{Name = 'Operating System'; Expression = { $_.os } }, @{Name = 'Total Monitors'; Expression = { $_.totalActiveMonitors } }, @{Name = 'Down Monitors'; Expression = { $_.totalActiveMonitorsDown } }, @{Name = 'Up Monitors'; Expression = { $_.totalActiveMonitors - $_.totalActiveMonitorsDown } }, @{Name = 'Device ID'; Expression = { $_.id } }

    # TODO how to sort these in a desired order
    $DevicesHeaders = $Devices | Get-Member | Where-Object membertype -EQ noteproperty | Select-Object -ExpandProperty name

    foreach ($Header in $DevicesHeaders) {
        $WhatsUpGold_FilterComboBox.Items.Add($Header)
    }
    $Script:Datatable = New-Object System.Data.DataTable
    $Datatable.Columns.AddRange($DevicesHeaders)
    foreach ($Device in $Devices) {
        $Array = @()
        Foreach ($Header in $DevicesHeaders) {
            $array += $Device.$Header
        }
        $Datatable.Rows.Add($array)
    }
    $WhatsUpGold_DeviceListingDataGrid.ItemsSource = $Datatable.DefaultView
}