Leigh Ciechanowski
Leigh Ciechanowski

Reputation: 1317

PowerShell Get-ChildItem search in the directory Above

I want to search for a file in the parent directory. So far I have

Get-ChildItem -Filter *.xap

What I want is to search for this file in the parent directory (the file is located in another folder in the parent folder). Any advice on how to do this with PowerShell?

Upvotes: 0

Views: 1192

Answers (1)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174465

Specify the Path parameter with a value of .., so use the parent directory as the base of your search:

Get-ChildItem -Path .. -Filter *.xap

If the file(s) you're looking for are not located directly inside the parent directory, but another subdirectory of the parent, either use the -Recurse switch parameter to perform a recursive search, or use .. in a relative path:

Get-ChildItem -Path ..\otherfolder

or

Get-ChildItem -Path .. -Recurse

Upvotes: 1

Related Questions