-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest-Non-ASCII.ps1
More file actions
53 lines (44 loc) · 1.23 KB
/
Test-Non-ASCII.ps1
File metadata and controls
53 lines (44 loc) · 1.23 KB
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
43
44
45
46
47
48
49
50
51
52
53
<#
.SYNOPSIS
Check if value contains non-ASCII characters.
.DESCRIPTION
Check if value contains non-ASCII characters.
.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 Value, Path or FullName.
.OUTPUTS
System.String. Returns the value if it contains non-ASCII characters.
.EXAMPLE
PS> .\Test-Non-ASCII.ps1 -Value 'Some Value®'
Some Value®
.EXAMPLE
PS> Get-ChildItem -Path $HOME | .\Test-Non-ASCII.ps1
C:\Users\MyUser\Some Folder®
C:\Users\MyUser\Some Value®.txt
.EXAMPLE
PS> Get-ChildItem -Path $HOME -File | .\Test-Non-ASCII.ps1
C:\Users\MyUser\Some Value®.txt
#>
[CmdletBinding()]
[OutputType([System.Management.Automation.PSCustomObject])]
Param(
[parameter(Mandatory=$true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Alias('FullName')]
[Alias('Path')]
[string]
$Value
)
PROCESS {
$result = ($Value -cmatch '[^\x20-\x7F]')
if ($result -eq $true)
{
Write-Output $Value
}
}