Public/Get-ADPLocation.ps1

function Get-ADPLocation {
    <#
    .SYNOPSIS
        Get a user's Location from ADP

    .DESCRIPTION
        Get a user's Location from ADP

    .PARAMETER ADPObject
        Object which holds the Location

    .EXAMPLE
        Input Object: ADP Object
        Return Object: {street, city, state, zipCode, country}

    .NOTES
        This is used when passing the full adp worker object from ADP's APID

    .FUNCTIONALITY
        Powershell Language
    #>

    [CmdletBinding()]
    param (
        [Parameter( Mandatory = $true,
            Position = 0,
            ValueFromPipeline = $true
        )]
        $ADPObject
    )

    $localOrganization = ( $ADPObject | Get-ADPOrganization )

    $localLocation = [PSCustomObject]@{
        street  = "";
        city    = "";
        state   = "";
        zipCode = "";
        country = "";
    }

    switch ($localOrganization) {
        "WorkBoard" {
            try {
                $localLocation.street += $ADPObject.person.legalAddress.lineOne
            }
            catch {}

            try {
                $localLocation.street += " "
                $localLocation.street += $ADPObject.person.legalAddress.lineTwo
            }
            catch {}

            try {
                $localLocation.street += " "
                $localLocation.street += $ADPObject.person.legalAddress.lineThree
            }
            catch {}

            try {
                $localLocation.city = $ADPObject.person.legalAddress.cityName
            }
            catch {}

            try {
                $localLocation.state = $ADPObject.person.legalAddress.countrySubdivisionLevel1.codeValue
            }
            catch {}

            try {
                $localLocation.zipCode = $ADPObject.person.legalAddress.postalCode
            }
            catch {}

            try {
                $localLocation.country = $ADPObject.person.legalAddress.countryCode
            }
            catch {}
            break
        }
        "Happiest Minds" {
            $localLocation.street = "53/1-4, Hosur Main Road, Madiwala"
            $localLocation.city = "Karnataka"
            $localLocation.state = "Bangalore"
            $localLocation.zipCode = "560068"
            $localLocation.country = "IN"
            break
        }
        "US Launchpad" {
            $localLocation.street = $null
            $localLocation.city = $null
            $localLocation.state = $null
            $localLocation.zipCode = $null
            $localLocation.country = $null
        }

        "Pop-Up Talent" {
            $localLocation.street = "50 Woodside Plaza #604"
            $localLocation.city = "Redwood City"
            $localLocation.state = "CA"
            $localLocation.zipCode = "94061"
            $localLocation.country = "US"
        }

        default { }
    }

    $localLocation.street = ( $localLocation.street | Get-ValidADPReturn )
    $localLocation.city = ( $localLocation.city | Get-ValidADPReturn )
    $localLocation.state = ( $localLocation.state | Get-ValidADPReturn )
    $localLocation.zipCode = ( $localLocation.zipCode | Get-ValidADPReturn )
    $localLocation.country = ( $localLocation.country | Get-ValidADPReturn )

    return $localLocation
}