-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-Non-ASCII-Files.ps1
42 lines (34 loc) · 1.14 KB
/
Get-Non-ASCII-Files.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<#
.SYNOPSIS
Find files in the specified path that have non-ASCII characters in filenames.
.DESCRIPTION
Find files in the specified path that have non-ASCII characters in filenames.
.NOTES
Author: Jonathan Panning <jpann [at] impostr-labs.com>
Created on: 12-06-2023
Version: 1.0
Last updated: 12-06-2023
.INPUTS
System.String. Accepts objects piped with the property Path or Directory.
.OUTPUTS
System.String[]. Returns an array containing the paths of files that
contain non-ASCII characters in their filenames.
.EXAMPLE
PS> .\Get-Non-ASCII-Files.ps1 -Path 'C:\temp'
C:\temp\Some Value®.txt
#>
[CmdletBinding()]
[OutputType([System.Management.Automation.PSCustomObject[]])]
Param(
[parameter(Mandatory=$true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Alias('Directory')]
[string]
$Path
)
PROCESS {
$files = [System.IO.Directory]::EnumerateFiles($Path, '*', [System.IO.SearchOption]::AllDirectories)
$files | Where-Object {$_ -cmatch '[^\x20-\x7F]'} | Write-Output
}