Monthly Archive


Scripting Games Comments IX: test-path

One more event to go after today and the Games begin to wind down.  I’ve looked at over 1000 scripts – mainly PowerShell – over the course of the Games and have been very impressed with the standard of the entries. There have been some very innovative answers – I suspect that some of the innovation has been due to not knowing how to do something in PowerShell and looking for ways  round that gap.

I’ve posted a number of comments on things I’ve noticed and there are a few more to come.  Some waiting on the closure of events,

One thing I did notice was the use of Test-Path

PS> Test-Path c:\scripts

PS> Test-Path c:\scriptz

Test-Path returns a boolean – true\false

If you want to use test-path in a test just use

if (Test-Path c:\scripts){}


if (-not(Test-Path c:\scriptz)){}

Nice easy single step

Leave a Reply