Public/Get-SpecAzTable.ps1

function Get-SpecAzTable {
    <#
    .SYNOPSIS
    Retrieves the entire contents of an Azure table.
 
    .DESCRIPTION
    This function retrieves all the records from an Azure table specified by the table name, resource group, and storage account. It uses the Azure PowerShell module (Az.Storage) to interact with the Azure Storage service.
 
    .PARAMETER TableName
    The name of the Azure table from which to retrieve the contents. This parameter is mandatory.
 
    .PARAMETER tableResourceGroup
    The resource group of the Azure Storage account containing the table. This parameter is mandatory.
 
    .PARAMETER tableStorageAccount
    The name of the Azure Storage account containing the table. This parameter is mandatory.
 
    .EXAMPLE
    Get-SPECAzTable -TableName "MyTable" -tableResourceGroup "MyResourceGroup" -tableStorageAccount "MyStorageAccount"
 
    This example retrieves all the records from the Azure table named "MyTable" in the storage account "MyStorageAccount" within the resource group "MyResourceGroup".
 
    .INPUTS
    This function accepts input through its parameters.
 
    .OUTPUTS
    This function outputs an array of table records retrieved from the specified Azure table. (system.array)
     
    It will return various error numbers depending on the error:
        501 - Storage account not found
        502 - Table Not found
 
    .NOTES
    Author: owen.heaume
    Version: - 1.0 Initial release
             - 1.1 fix unicode issue
             - 1.2 Remove Exit codes and replace with return numbers
    #>

    [cmdletbinding()]
    param
    (
        [Parameter(Mandatory = $true)]
        [string]$TableName,

        [Parameter(Mandatory = $true)]
        [string]$tableResourceGroup,

        [Parameter(Mandatory = $true)]
        [string]$tableStorageAccount
    )

    Begin {
        # clean up leading and trailing whitespace in vars
        $TableName = $TableName.Trim()
        $tableResourceGroup = $tableResourceGroup.Trim()
        $tableStorageAccount = $tableStorageAccount.Trim()

        # Get the table to work with
        $cloudTable = get-specCloudtable -TableName $TableName -tableResourceGroup $tableResourceGroup -tableStorageAccount $tableStorageAccount

        # Check for errors
        switch ($cloudTable) {
            501 { return 501 }
            502 { return 502 }
        }   
    }

    process {     
        $tableresult = Get-AzTableRow -table $cloudTable

        if ($null -eq $tableresult) {
            Write-Warning "No records found in the table: $TableName"
        }

        Return $tableResult
    }
}