![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Test-Path isValid parameter From the help file -isValid <SwitchParameter> Determines whether the syntax of the path is correct, regardless of whether the elements of the path exist. Returns TRUE if the path syntax is valid; FALSE if it is not. Should I rely on Test-Path's -isValid parameter ??? PS C:\Scripts> Test-Path c:\ -isValid True PS C:\Scripts> Test-Path c:\]] -isValid True PS C:\Scripts> Test-Path c:\\\ -isValid True PS C:\Scripts> Test-Path \\\ -isValid False PS C:\Scripts> Test-Path z\\\ -isValid True PS C:\Scripts> Test-Path z\\\// -isValid True PS C:\Scripts> Test-Path shay-levi -isValid True Shay http://scriptolog.blogspot.com |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Test-Path isValid parameter On Sep 19, 6:26 pm, Shay Levi <n...@xxxxxx> wrote: Quote: > From the help file > > -isValid <SwitchParameter> > Determines whether the syntax of the path is correct, regardless of whether > the elements of the path exist. Returns TRUE if the > path syntax is valid; FALSE if it is not. > > Should I rely on Test-Path's -isValid parameter ??? > > PS C:\Scripts> Test-Path c:\ -isValid > True > > PS C:\Scripts> Test-Path c:\]] -isValid > True > > PS C:\Scripts> Test-Path c:\\\ -isValid > True > > PS C:\Scripts> Test-Path \\\ -isValid > False > > PS C:\Scripts> Test-Path z\\\ -isValid > True > > PS C:\Scripts> Test-Path z\\\// -isValid > True > > PS C:\Scripts> Test-Path shay-levi -isValid > True > > Shayhttp://scriptolog.blogspot.com validity, not exists etc. - Oisin |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Test-Path isValid parameter The -isValid switch parameter checks for the presence of 'invalid' filename characters... " * : < > ? | ....if present it returns $false. 32..255|?{!(test-path "$([char]$_)" -isValid)}|%{[char]$_} Could be used to ensure the validity of randomly generated file names for example. -- Kiron |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Test-Path isValid parameter On Sep 20, 5:07 pm, "Kiron" <Ki...@xxxxxx> wrote: Quote: > The -isValid switch parameter checks for the presence of 'invalid' filename > characters... > " * : < > ? | > ...if present it returns $false. > > 32..255|?{!(test-path "$([char]$_)" -isValid)}|%{[char]$_} > > Could be used to ensure the validity of randomly generated file names for > example. I agree, although note that if you use [System.IO.Path]::GetRandomFileName() you get a nice random filename that contains only safe characters: http://pageofwords.com/blog/default.aspx?page=admin Kirk |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Test-Path isValid parameter Thank you guys. Shay http://scriptolog.blogspot.com Quote: > From the help file > > -isValid <SwitchParameter> > Determines whether the syntax of the path is correct, regardless > of whether > the elements of the path exist. Returns TRUE if the > path syntax is valid; FALSE if it is not. > Should I rely on Test-Path's -isValid parameter ??? > > PS C:\Scripts> Test-Path c:\ -isValid > True > PS C:\Scripts> Test-Path c:\]] -isValid > True > PS C:\Scripts> Test-Path c:\\\ -isValid > True > PS C:\Scripts> Test-Path \\\ -isValid > False > PS C:\Scripts> Test-Path z\\\ -isValid > True > PS C:\Scripts> Test-Path z\\\// -isValid > True > PS C:\Scripts> Test-Path shay-levi -isValid > True > Shay > http://scriptolog.blogspot.com |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Test-Path isValid parameter Thanks Kirk. Good tip. -- Kiron |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| test-path -IsValid ? | PowerShell | |||
| test for executable on path | PowerShell | |||
| Test-Path '' -IsValid does not return False but fails. Is this OK? | PowerShell | |||
| how to test for a program in my path? | PowerShell | |||
| BUG? (Test-Path $path -IsValid) and empty $path | PowerShell | |||