none
Does a file exist in any of the subfolders

    Question

  • I need to check whether a .trn file exists within any of the sub-folders and want to return a true or false

    if I use

    Get-ChildItem \\SERVERNAME\i$\Backup -recurse -include *.trn | select -First 1

    I can see whether it exists or not. But as this forms part of a script I need TRUE or FALSE returned

    Using test-path should work but that does not seem to allow -recurse

    test-path \\SERVERNAME\i$\Backup -recurse -include *.trn | select -First 1  # This fails

    Ultimately I want to add this into a loop and report on all servers that contain *.trn files

    Wednesday, April 19, 2017 2:13 PM

Answers