I need to get just the last part of the path name for a file.
Example:
c:\dir1\dir2\dir3\file.txt
I need to get dir3 into a variable.
dir3
I have been trying with Split-Path, but it gives me the whole path.
Split-Path
If you want to keep it simple and the path is going to be in normal form, you can use String.Split():
String.Split()
"c:\dir1\dir2\dir3\file.txt".split("\")[-2]