Public/Find-ADUser.ps1
Function Find-ADUser { <# .SYNOPSIS Find ADUser .DESCRIPTION Find ADUser .PARAMETER Identifier The Identifier used to identify the user .INPUTS None .OUTPUTS None .EXAMPLE Find-ADUser -Identifier someuser@somedomain.tld .EXAMPLE Find-ADUser -Identifier bd8be4f8-317b-4246-8b87-99f9cb14cf51 .LINK about_functions_advanced .LINK about_CommonParameters #> [Cmdletbinding()] param ( [string]$Identifier ) switch ($Identifier) { { $_ -match "@" } { if (get-aduser -Filter "UserPrincipalName -eq '$_'") { Return $True } else { Return $False } } { Try { Test-GUID $_ } catch { } } { if (Get-ADUser -Id $_) { Return $True } else { Return $False } } default { Write-warning "No valid identifier" } } } |