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('PSObject')]
    Param ()
    Begin {
        $PSBoundParameters.Properties = "Name", "HomeDirectory"
        $PSBoundParameters.Filter = "*"
        $HomeDirectories = @()
    }
    Process {
        Try {
            $Users = Get-ADUser @PSBoundParameters

            Foreach ($User in $Users) {
                $properties = @{
                    Name          = $User.Name
                    HomeDirectory = $User.HomeDirectory
                }

                $obj = New-Object -TypeName PSObject -Property $properties

                $HomeDirectories += $obj
            }
        } Catch {
            Write-Warning $_.Exception.Message
            Foreach ($User in $Users) {
                $properties = @{
                    Name          = $User.Name
                    HomeDirectory = $User.HomeDirectory
                }

                $obj = New-Object -TypeName PSObject -Property $properties

                $HomeDirectories += $obj
            }
        }
    }
    End {
        Write-Output $HomeDirectories
    }
}
Set-Alias -Name Show-HomeDirectory -Value Get-HomeDirectory -Description "Get Homedirectories" -Option ReadOnly -PassThru -ErrorAction SilentlyContinue