Last active
April 12, 2016 05:57
-
-
Save KirillPashkov/59a266b2195f9863da0483caf23969ab 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
Function Get-Diacritic | |
{ | |
Param | |
( | |
[Parameter(Mandatory=$true)][ValidateScript({Test-Path $_})][String]$Path, | |
[Parameter(Mandatory=$True)][String[]]$Recepient, | |
[Switch]$AsHTML | |
) | |
$email = @{ | |
'To' = $Recepient; | |
'SmtpServer' = 'mysmtp.server.com'; | |
'From' = 'powershelldudey'; | |
'Subject' = "Diacritic files $([datetime]::now)" | |
} | |
[System.Collections.ArrayList]$Files = gci $Path -Recurse | ? {[int[]][char[]]$_.name -gt 192} | select Name, @{l='Directory'; e={$_.DirectoryName}}, ` | |
@{l='Created'; e={$_.CreationTime}}, ` | |
@{l='Modified'; e={$_.LastWriteTime}},` | |
@{l='Size'; e={switch ($_.Length){ ` | |
{$_ -lt [math]::pow(2,20)} {"$([math]::Round($_/[math]::pow(2,10),2)) Kb"; break} | |
{$_ -lt [math]::pow(2,30)} {"$([math]::Round($_/[math]::pow(2,20),2)) Mb"; break} | |
{$_ -lt [math]::pow(2,40)} {"$([math]::Round($_/[math]::pow(2,30),2)) GB"; break} | |
} | |
} | |
} | |
if ($files.Count -gt 0){ | |
$filepath = "$([Environment]::GetEnvironmentVariable('TEMP','Machine'))\$(Get-Date -Format yyyyMMdd)_FileNamesWithDiacritics.csv" | |
$files | Export-Csv -Path $filepath | |
$email.Add('Attachments',$filepath) | |
$email.Add('Body',$files) | |
if ($AsHTML){ $email.Add('BodyAsHtml',$true)} | |
Send-MailMessage @email | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment