Public/Get-HomeDirectory.ps1

Function Get-HomeDirectory {
    <#
        .SYNOPSIS
            Get list of Homedirectory's
        .DESCRIPTION
            Get list of Homedirectory for all ActiveDirectory users
        .INPUTS
            None
        .EXAMPLE
            PS C:\> Get-HomeDirectory
        .LINK
            about_functions_advanced
        .LINK
            about_CommonParameters
    #>

    [CmdletBinding(
        SupportsPaging = $true
    )]
    [OutputType('JBOADS.HomeDirectory.List')]
    Param ()
    Begin {
        $PSBoundParameters.Properties = "Name", "HomeDirectory"
        $PSBoundParameters.Filter = "*"
        $HomeDirectories = [System.Collections.Generic.List[object]]::new()
    }
    Process {
        Try {
            $Users = Get-ADUser @PSBoundParameters
            Foreach ($User in $Users) {
                $properties = @{
                    Name          = $User.Name
                    HomeDirectory = $User.HomeDirectory
                }
                $obj = New-Object -TypeName PSObject -Property $properties
                $null = $HomeDirectories.Add($obj)
            }
        } Catch {
            Write-Warning $_.Exception.Message
            Foreach ($User in $Users) {
                $properties = @{
                    PSTypeName    = "JBOADS.HomeDirectory.List"
                    Name          = $User.Name
                    HomeDirectory = $User.HomeDirectory
                }
                $obj = New-Object -TypeName PSObject -Property $properties
                $null = $HomeDirectories.Add($obj)
            }
        }
    }
    End {
        Write-Output $HomeDirectories
    }
}
Set-Alias -Name Show-HomeDirectory -Value Get-HomeDirectory -Description "Get Homedirectories" -Option ReadOnly -PassThru -ErrorAction SilentlyContinue