Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "." and [System.ENVIRONMENT]::CurrentDirectory in powershell?

PM> $path = "."
PM> Get-ChildItem $path -filter '.nuget'


    Directory: C:\Users\david\Documents\Visual Studio 2010\Projects\...


Mode                LastWriteTime     Length Name                                                                                                                                                                
----                -------------     ------ ----                                                                                                                                                                
d----        25.05.2012     16:20            .nuget                                                                                                                                                              


PM> $cwd = [System.ENVIRONMENT]::CurrentDirectory
PM> $cwd
C:\Windows\system32
PM> Get-ChildItem $cwd -filter '.nuget'
PM> Get-ChildItem $cwd -filter 'adsnt.dll'


    Directory: C:\Windows\system32


Mode                LastWriteTime     Length Name                                                                                                                                                                
----                -------------     ------ ----                                                                                                                                                                
-a---        14.07.2009     03:14     260608 adsnt.dll                                                                                                                                                           


PM> [System.IO.PATH]::GetFullPath(".")
C:\Windows\system32
PM>
like image 445
David Schmitt Avatar asked Feb 21 '23 08:02

David Schmitt


1 Answers

[System.Environment]::CurrentDirectory returns the working directory of the PowerShell process. To get the working directory of the console session use the Get-Location cmdlet (or pwd, $pwd).

Note that this "working directory" could also be a location in the registry or any of a number of other location providers.

like image 83
Shay Levy Avatar answered May 10 '23 07:05

Shay Levy