PowerShellを使用してファイルが存在するが、その方法を考えることができないすべてのgrand-parentディレクトリを探したいと思います。私はこのような何かをする必要があります考え出し:ファイルが存在するすべてのGrand-Parentディレクトリを見つけるには
Get-ChildItem -Filter MyApp.exe -Recurse | format-table Directory
は、私は次のような場所にファイルがあるとします。
C:\test\AppA\201608114\MyApp.exe
C:\test\AppA\20160812a\MyApp.exe
C:\test\AppA\201608136\MyApp.exe
C:\test\AppB\201607115\MyApp.exe
C:\test\AppB\201607104\MyApp.exe
C:\test\OtherApps\AppC\201606234\MyApp.exe
したがって、上記の例では、私は出力にPowerShellを希望:
C:\test\AppA
C:\test\AppB
C:\test\OtherApps\AppC
Powershellでこれを実現する方法はありますか?ほとんどこれだけのためのPerl/Pythonスクリプトを書いている時点で、私は単純にファイルディレクトリの親を取得PowerShellのにそれ最初
これらはすべて祖父母ですディレクトリ... –