Last active
March 12, 2016 12:28
-
-
Save helu2016/4456125a8ad0aa8e5a1a to your computer and use it in GitHub Desktop.
PowerShell Games 2016-03 (www.powershell.org)
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
<# | |
.Synopsis | |
Test-Latin1Letter tests if a string contains a letter for the Latin1 table. | |
.DESCRIPTION | |
The function Test-Latin1Letter returns $true if the tested string contains a letter which is in the Latin1 table of UFT8. | |
To mathematical operators (multiplication sign and division sign) are not included. | |
.EXAMPLE | |
"øre" | Test-Latin1Letter | |
$true | |
.INPUTS | |
[string[]] | |
.OUTPUTS | |
[bool] | |
.NOTES | |
Author: Hermann Lupfert | |
Date: 03/12/2016 | |
.LINK | |
https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block) | |
#> | |
function Test-Latin1Letter | |
{ | |
[CmdletBinding()] | |
Param | |
( | |
#The string to be tested. | |
[Parameter(Mandatory=$true, | |
ValueFromPipeline=$true, | |
Position=0 | |
)] | |
[ValidateNotNullOrEmpty()] | |
[string[]]$Strings | |
) | |
Begin | |
{ | |
} | |
Process | |
{ | |
foreach ($String in $Strings) | |
{ | |
$i = 0 | |
$Letters = $String.GetEnumerator() | |
foreach ($Letter in $Letters) | |
{ | |
$LetterNumber = [int]([char]$Letter) | |
if (($LetterNumber -in 192..214) -or ($LetterNumber -in 216..246) -or ($LetterNumber -in 248..255)) | |
{ | |
$i++ | |
}#end if | |
}#end foreach letter | |
[bool]$i | |
}#end foreach string | |
}#end process | |
End | |
{ | |
}#end end | |
}#end function | |
############################################################################################ | |
$SharePath = 'c:\ps' | |
If (Test-Path $SharePath){ | |
$all_files = Get-ChildItem -Path $SharePath -File -Recurse -Force | |
$basenames = $all_files.basename | Where-Object {($_ | Test-Latin1Letter) -eq $true} | |
$result_files = $all_files | where basename -in $basenames | |
$result_files | Select-Object Name,Directory,@{n='Creation Date';e=({($_.creationtime)})},@{n='Last Modification Date';e=({($_.lastwritetime)})},@{n='File Size';e=({$_.Length})} | Format-Table | |
} | |
else {Write-Warning "Path $SharePath not found."} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment