Last active
July 8, 2017 23:37
-
-
Save turboBasic/50c6ea536150d5fdcbfa2ff5fc88391d to your computer and use it in GitHub Desktop.
Test if $fileName is valid file name. Answers question "How do I check if $fileName is completely valid file name in Windows 10?"
This file contains hidden or 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 Test-FilenameValid { | |
PARAM( [PARAMETER( Mandatory )] | |
[String] | |
$filename | |
) | |
# IndexOfAny returns -1 if there is no any characters from argument in the string | |
$filename.IndexOfAny( [System.IO.Path]::GetInvalidFileNameChars() ) -eq -1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment