Character ASCII checking


Checking for non ASCII characters in a String

Function CheckLine($LineSpecChar){ 
    $Split = [regex]::split($linespecchar,"")
    foreach ($item in $split){
        $ASCII = [int]$item[-0];
        if (!($ASCII -ge '32' -and $ASCII -le '123' -or $ASCII -eq '0')){
            Write-output "Character $i | '$item' | [$ASCII] | Not a valid ASCII Character in $linespecchar"

$line = "C:\Cluster–Storage\Volume–2\Server (Name – Location)"
CheckLine $line


About the Author


I am a Technical Specialist - Cloud Infrastructures from the Netherlands. My Skills are mainly PowerShell, VMWare, Hyper-V, Microsoft System Center products and Windows Azure Pack. I work for a company in Utrecht The Netherlands.

No Comments

Comments are closed.