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
Would the following work for you?
$trntest = gci "\\SERVERNAME\i$\Backup" -Filter "*.trn"
Microsoft is conducting an online survey to understand your opinion of the Technet Web site. If you choose to participate, the online survey will be presented to you when you leave the Technet Web site.
Would you like to participate?