Public/Get-Team.ps1

Function Get-Team {
    [CmdletBinding()]
    param (
        [Parameter(
            ValueFromPipelineByPropertyName
        )]
        $Manager,
        [Parameter(
            ValueFromPipeline
        )]
        $Search = $ENV:USERNAME,
        [string[]]$Properties = @("Name", "EmployeeID", "physicalDeliveryOfficeName", "Title", "mail", "msRTCSIP-PrimaryUserAddress", "CanonicalName", "DistinguishedName", "samaccountname", "UserPrincipalname", "AccountExpirationDate", "Enabled", "Manager", "badPwdCount", "LastBadPasswordAttempt", "LockedOut", "LockOutTime", "lastLogonDate", "PasswordExpired", "PasswordLastSet", "whenCreated", "whenChanged"),
        [string[]]$Select = @("Name", "EmployeeID", "physicalDeliveryOfficeName", "Title", "mail", "msRTCSIP-PrimaryUserAddress", "CanonicalName", "DistinguishedName", "samaccountname", "UserPrincipalname", "AccountExpirationDate", "Enabled", "Manager", "badPwdCount", "LastBadPasswordAttempt", "LockedOut", "LockOutTime", "lastLogonDate", "PasswordExpired", "PasswordLastSet", "whenCreated", "whenChanged")
    )
    BEGIN {}
    PROCESS {
        if ($Manager) {
            Write-Verbose "Searching based on ($Manager)"
            $Users = Get-ADUser -Filter "manager -eq '$Manager'" -Properties $Properties | Select-Object $Select
            Return $Users
        }
        elseif ($Search) {
            $Users = @()
            foreach ($SearchTerm in $Search) {
                $Manager = (Get-ADUser -Filter "SamAccountName -eq '$SearchTerm' -or UserPrincipalName -eq '$SearchTerm' -or employeeid -eq '$SearchTerm'" -Properties Manager).Manager
                $Users += Get-ADUser -Filter "manager -eq '$Manager'" -Properties $Properties | Select-Object $Select
            }  
            Return $Users     
        }
        else {
            Write-Warning "No Search Info Provided"
        } 
    }
    END {}
}