1

I am trying to return a boolean for a specific file within a directory from within a script when I use the first command within the local directory it works and the function seeing a file returns True, and my statement launches.

get-childitem *agc.txt

Once I move back one directory the function no longer works.

get-childitem -path test -include agc.txt

The end result is to have networked paths.

Jayson
  • 51
  • 2

1 Answers1

0

The Include parameter is effective only when the command includes the contents of an item, such as C:\Windows*, where the wildcard character specifies the contents of the C:\Windows directory

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7.2

So do:

get-childitem -path test* -include agc.txt

and you get agc.txt. To get any file ending with agc.txt, specify *agc.txt.

Toni
  • 1,738
  • 1
  • 3
  • 11