Created
March 17, 2016 17:04
-
-
Save jeffbuenting/6e47f34b305daf89c29d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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