Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enter file contents hereFunction Get-Diacritic {
<#
.Synopsis
Creates a report of files that do not contain diacritic characters.
.Description
Emails a report of files that do not contain diacritic characters ( ascii chars between 80 and FF hex )
.Parameter Searchroot
Folder to begin the search
.Parameter Sendto
Email of person to who will recieve the report
.Parameter SMTPServer
IP address of the SMTPServer
.Example
Get-Diacritic -SearchRoot F:\FileShare -Sendto Jeff.buenting@email.com -SMTPServer mail.stratuslive.com
#>
[CmdletBinding()]
Param (
[Parameter( Mandatory=$True)]
[String]$SearchRoot,
[Parameter( Mandatory=$True)]
[String[]]$Sendto,
[Parameter( Mandatory=$True)]
[String]$SMTPServer
)
Write-Verbose "Checking $SearchRoot for Diacritic marks"
$DiaCriticFiles = Get-ChildItem -Path F:\FileShare -recurse | where name -Match '[\u0080-\u00ff]'
Write-Verbose "Sending Filename report"
Send-MailMessage -To $Sendto -From ServerMonitor@Corp.com -SmtpServer $SMTPServer -Subject 'Files with diacritical marks' -Body "Scan of $(Get-Date -UFormat '%Y-%m-%d'): $(DiacriticFiles.Count) filenames with diacritic marks found under $SearchRoot`n`n$($DiacriticFiles | ft Name,Directory,@{N='Creation Date';E={$_.CreationTime}},@{N='Last Modification Date';E={$_.LastWriteTime}},@{N='File Size';E={$_.Length}} -AutoSize) "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment