Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Use PowerShell to Find Grandparent of Path

$
0
0

Summary: Use Windows PowerShell to easily find the grandparent of a path.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find a directory that is two levels up in a nested path?

Hey, Scripting Guy! Answer Use the Split-Path cmdlet and pipe the results to Split-Path. In the following example,
          the path to a Windows PowerShell module is split, and then the parent of that path is split again:

(get-module -l)[0].Path | split-path -Parent | Split-Path -Parent


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>