Public/Get-User.ps1

Function Get-User {
    <#
.SYNOPSIS
    This is a basic overview of what the script is used for..
  
  
.NOTES
    Name: Get-Something
    Author: Luke Hagar
    Version: 1.0
    DateCreated: January 20th, 2021
  
  
.EXAMPLE
    Get-Something -UserPrincipalName "Luke.Hagar"
  
  
.LINK
     
#>

    
    [CmdletBinding()]
    param (
        [Parameter(
            ValueFromPipelineByPropertyName
        )]
        $distinguishedName,
        $Search,
        [string[]]$Properties = @("Name", "EmployeeID", "physicalDeliveryOfficeName", "Title", "mail", "msRTCSIP-PrimaryUserAddress", "CanonicalName", "samaccountname", "UserPrincipalname", "AccountExpirationDate", "Enabled", "Manager", "badPwdCount", "LastBadPasswordAttempt", "LockedOut", "LockOutTime", "lastLogonDate", "PasswordExpired", "PasswordLastSet", "whenCreated", "whenChanged"),
        [string[]]$Select = @("Name", "EmployeeID", "physicalDeliveryOfficeName", "Title", "mail", "msRTCSIP-PrimaryUserAddress", "CanonicalName", "samaccountname", "UserPrincipalname", "AccountExpirationDate", "Enabled", "Manager", "badPwdCount", "LastBadPasswordAttempt", "LockedOut", "LockOutTime", "lastLogonDate", "PasswordExpired", "PasswordLastSet", "whenCreated", "whenChanged")
    )
    
    BEGIN { }
    
    PROCESS {
        if ($DistinguishedName) {
            Get-ADUser $DistinguishedName -Properties $Properties | Select-Object $Select
        }
        elseif ($Search) {
            Foreach ($SearchValue in $Search) {
                Get-ADUser -Filter "employeeid -eq $SearchValue -or mail -eq '$SearchValue' -or samaccountname -eq '$SearchValue' -or distinguishedName -eq '$SearchValue'" -Properties $Properties | Select-Object $Select
            }
        }
    }
    
    END { }
}