PoshBot.AD.psm1
$scoobyDooUri = 'https://raw.githubusercontent.com/poshbotio/PoshBot/master/Media/scooby_doo.jpg' function Invoke-GetAdUserTel { <# .SYNOPSIS Searching users in AD by part of mobile number. Minimum required numbers is 3. It's presumed that account under which PoshBot is runing is standard AD user, and no special AD permission is required. .PARAMETER tel Mobile number or part of it. .EXAMPLE !usertel --tel '1234' or !usertel '1234' #> [PoshBot.BotCommand( CommandName = 'usertel' # Permissions = 'test-network' )] [cmdletbinding()] param( [parameter(Mandatory)] [Alias('Name')] [string]$tel ) switch -regex ($tel) { '\d{3}' { $r = get-aduser -filter "mobile -like '*$($tel)*'" -properties Name,Mobile -ErrorAction SilentlyContinue | Select-Object Name,Mobile | Format-Table -Autosize | Out-String if ($r) { New-PoshBotCardResponse -Type Normal -Text $r } else { New-PoshBotCardResponse -Type Warning -Text "Unable to find users with mobile as requested :(" -Title 'Rut row' -ThumbnailUrl $scoobyDooUri } } default { New-PoshBotCardResponse -Type Warning -Text "Please enter at least 3 numbers to check !" -Title 'Rut row' -ThumbnailUrl $scoobyDooUri } } } Export-ModuleMember -Function 'Invoke-GetAdUserTel' |