Public/Get-specFilteredTableData.ps1
Function Get-specFilteredTableData { <# .SYNOPSIS Filters Azure table data based on specified criteria. .DESCRIPTION This function filters Azure table data based on the specified parameters: Device, Persona, EPOS, and Country. .PARAMETER tableData Specifies the array containing the table data to be filtered. .PARAMETER Device Specifies the device type to filter the table data. .PARAMETER Persona Specifies the persona to filter the table data. .PARAMETER EPOS Specifies the EPOS (Electronic Point of Sale) to filter the table data. .PARAMETER Country Specifies the country to filter the table data. .EXAMPLE Get-specFilteredTableData -tableData $tableData -Device "Laptop" Retrieves table data filtered by the specified device type. .EXAMPLE Get-specFilteredTableData -tableData $tableData -Persona "Tills" -EPOS "1234" Retrieves table data filtered by the specified persona and EPOS. .NOTES Author: owen.heaume Version: 1.0.0 Intial release #> [cmdletbinding()] param( [array]$tableData, [string]$Device, $Persona, $EPOS, $Country ) Begin { $finalData = @() $tableFilters = @('Device', 'Persona', 'EPOS', 'Country') } process { foreach ($row in $tableData) { if ($row.Device -eq 'ALL' -and $row.Persona -eq 'ALL' -and $row.EPOS -eq 'ALL' -and $row.Country -eq 'ALL') { $finalData += $row } foreach ($item in $tableFilters) { if ($item -eq 'Persona') { $finalData += $row | Where-Object { $row.Persona -ne 'ALL' -and $row.EPOS -eq 'ALL' -and $row.country -eq 'ALL' -and $row.device -eq "ALL" -and $row.persona -eq $Persona } $finalData += $row | Where-Object { $row.EPOS -ne 'ALL' -and $row.Device -eq 'ALL' -and $row.country -eq "ALL" -and $row.Persona -eq $persona -and $row.EPOS -eq $EPOS } # Persona AND EPOS } if ($item -eq 'Device') { $finalData += $row | Where-Object { $row.Device -ne 'ALL' -and $row.EPOS -eq 'ALL' -and $row.country -eq 'ALL' -and $row.Persona -eq 'ALL' -and $row.Device -eq $Device } } if ($item -eq 'EPOS') { $finalData += $row | Where-Object { $row.EPOS -ne 'ALL' -and $row.persona -eq 'ALL' -and $row.Device -eq 'ALL' -and $row.country -eq "ALL" -and $row.EPOS -eq $EPOS } $finalData += $row | Where-Object { $row.EPOS -ne 'ALL' -and $row.persona -eq 'ALL' -and $row.Device -eq 'ALL' -and $row.country -eq "ALL" -and $row.Device -eq $Device -and $row.EPOS -eq $EPOS } # Device AND EPOS } if ($item -eq 'Country') { $finalData += $row | Where-Object { $row.country -ne "ALL" -and $row.Device -eq 'ALL' -and $row.EPOS -eq 'ALL' -and $row.Persona -eq "ALL" -and $row.country -eq $Country } $finalData += $row | Where-Object { $row.country -ne "ALL" -and $row.Device -ne 'ALL' -and $row.Persona -eq "ALL" -and $row.EPOS -eq 'ALL' -and $row.country -eq $Country -and $row.Device -eq $Device } #Country AND Device } } } } end { $finalData } } |