What is my current working directory? You can easily determine this if you are in a interactive shell, but how to get this information as part of script. This post will provide that information.
There are two ways available to get the current working directory using PowerShell.
Get-Location returns a object that contains the current path information. You can get it using the command shown below.
Get-Location | select -ExpandProperty Path
Using Dotnet class:
There is a dotnet way available as well. System.IO.Directory class provides this information. All you need to do is invoking the GetCurrentDirectory() method.
Which one you like most?