Get-NullThumbnailPhotoReport.ps1
function Get-NullThumbnailPhotoReport { <# .SYNOPSIS Short Description .DESCRIPTION Detailed Description .EXAMPLE Get-NullThumbnailPhotoReport -SMTPServer mail.company.com -email_recipient me@company.com -email_sender automation@company.com -email_cc user2@company.com #> [CmdletBinding()] param ( [Parameter(Mandatory=$true, Position=0)] [System.String] $SMTPServer, [Parameter(Mandatory=$true, Position=1)] [System.String] $email_recipient , [Parameter(Mandatory=$true, Position=2)] [System.String] $email_sender, [Parameter(Mandatory=$false, Position=3)] [System.String] $email_cc = '' ) $adusers = get-aduser -filter { Enabled -eq $true -and Division -ne "IT_ADMIN" -and Division -ne "Shared" -and Division -ne "CONTRACTOR" -and Division -ne "EMAIL" } -Properties thumbnailPhoto,Division,EmailAddress $html = $adusers | ? {$_.thumbnailphoto -eq $null} | sort samaccountname | select GivenName,SurName,samaccountname,EmailAddress | ConvertTo-Html -As Table [string]$body = $html if ($email_cc -like "*@*") { Send-MailMessage -SmtpServer $SMTPServer -From $email_sender -To $email_recipient -Subject "Null ThumbnailPhoto" -Body $body -BodyAsHtml -cc $email_cc } ELSE { Send-MailMessage -SmtpServer $SMTPServer -From $email_sender -To $email_recipient -Subject "Null ThumbnailPhoto" -Body $body -BodyAsHtml } } |