Public/Get-UserInfo.ps1

Function Get-UserInfo {
    <#
.SYNOPSIS
    Provide a search value or user object to either find or expand into relevant data
 
.NOTES
    Name: Get-UserInfo
    Author: Luke Hagar
    Version: 1.0
    DateCreated: 5/14/2021
 
.EXAMPLE
    Get-UserInfo -Identity "Luke.Hagar"
 
.EXAMPLE
    Get-UserInfo -Identity "CN=Luke Hagar (2187284),OU=Users,OU=CEN,OU=CE,OU=REGIONS,DC=wfm,DC=pvt"
 
.EXAMPLE
    $UserObject | Get-UserInfo
 
.EXAMPLE
    Get-UserInfo -Identity "Luke.Hagar"
 
.LINK
     
#>

    
    [CmdletBinding()]
    param (
        [Parameter(
            ValueFromPipeline,
            ValueFromPipelineByPropertyName
        )]
        [Alias("SamAccountName", "DistinguishedName", "GUID", "SID", "EmployeeID", "mail", "UserPrincipalName")]
        $Identity = $ENV:USERNAME,
        [string[]]$Properties = @("Name", "EmployeeID", "physicalDeliveryOfficeName", "Title", "mail", "msRTCSIP-PrimaryUserAddress", "CanonicalName", "DistinguishedName", "samaccountname", "UserPrincipalname", "AccountExpirationDate", "Enabled", "Manager", "MemberOf", "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", "MemberOf", "badPwdCount", "LastBadPasswordAttempt", "LockedOut", "LockOutTime", "lastLogonDate", "PasswordExpired", "PasswordLastSet", "whenCreated", "whenChanged")
    )
    
    BEGIN { }
    
    PROCESS {
        Foreach ($SearchValue in $Identity) {
            Get-ADUser -Filter "employeeid -eq '$SearchValue' -or SamAccountName -eq '$SearchValue' -or DistinguishedName -eq '$SearchValue' -or GUID -eq '$SearchValue' -or SID -eq '$SearchValue' -or EmployeeID -eq '$SearchValue' -or mail -eq '$SearchValue' -or UserPrincipalName -eq '$SearchValue'" -Properties $Properties | Select-Object $Select
        }
    }
    
    END { }
}