PowerShell
Edit|Remove
<#   
================================================================================ 
========= FilePath.ps1 ======================================= 
================================================================================ 
 Name: FilePath 
 Purpose: Demonstrate Multiple Ways to Obtain and work with File path Information 
 Author: Dan Stolts - dstolts&microsoft.com - http://ITProGuru.com 
 Syntax/Execution: Copy portion of script you want to use and paste into PowerShell (or ISE)  
                    Change file locations as needed to demonstrate files that exists   
 Description: Shows Multiple ways to work with location path information 
 Disclaimer: Use at your own Risk!  See details at http://ITProGuru.com/privacy  
 Limitations:  
         * Must Run PowerShell (or ISE)  
        * UAC may get in the way depending on your settings (See: http://ITProGuru.com/PS-UAC) 
        * Will need to change paths and file names to for script to function properly in your environment 
 ================================================================================ 
#> 
# File Path Using System.IO Namespace (Environment) 
# Class Definition https://msdn.microsoft.com/en-us/library/System.IO(v=vs.110).aspx  
# Working with System.IO 
[System.IO.Directory]::Exists("C:\Users\dstolts\ITProGuru-LogIt.log")  
# https://msdn.microsoft.com/en-us/library/system.io.directory(v=vs.110).aspx  
[System.IO.Directory]::Exists("C:\_Data\") 
[System.IO.File]::Exists("C:\_Data\TechNetwork.config") 
[System.IO.File]::Exists("B:\_ITCamp\DoesNotExist.txt"$LogFilePath = [System.IO.Directory]::GetCurrentDirectory() 
$LogFilePath  
 
################################################## 
 
# Using Get-Location 
$LogFilePath = Get-Location 
$LogfileName = "ITProGuru-LogIt.log"  
$myName"$LogFilePath\$LogFileName"  # Concatinate two strings separated by backslash 
$myName 
#Get-Location Details 
$LogFilePath.Drive 
$LogFilePath.Drive.Free 
$LogFilePath.Path 
$LogFilePath 
 
################################################## 
 
#Using Get-Item -Path https://technet.microsoft.com/en-us/library/hh849788.aspx 
$myPath = ((Get-Item -Path ".\").FullName + "\")   
$myPath  
 
# Split-Path: https://technet.microsoft.com/en-us/library/hh849809.aspx 
# Test-Path: https://technet.microsoft.com/en-us/library/hh849776.aspx 
 
# video of Script https://channel9.msdn.com/Series/GuruPowerShell 
# More scripts from Dan Stolts "ITProGuru" at http://ITProGuru.com/Scripts
 

There are several ways to work with files and paths with Powershell.  We will look at some of these in detail.  Get-Location is just the beginning.  You also need to know how to parse all that information.  Then concatinate multiple parts of a filename and path to make userable variables.  In addition to splitting Get-Location into multiple components we also look at obtaining free space, drive capacity and more.  We also look at [System.IO.Directory] and [System.IO.File] to manipulate files and determine if they exist.