Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get working directory in binary powershell module

I'm writing a binary powershell module in C# and I can't seem to find out to get the current working directory from within a command.

My first thought was to do a simple Directory.GetCurrentDirectory(); from the System.IO library but it only seems to give me the directory that powershell was launched in.

How can I get the current directory within a binary powershell module during a command execution?

Thanks

like image 689
jonfriesen Avatar asked Dec 18 '25 05:12

jonfriesen


1 Answers

Assuming your cmdlet derives from PSCmdlet, using CurrentProviderLocation("FileSystem").ProviderPath should do the job nicely (untested).

like image 189
Nathan Tuggy Avatar answered Dec 19 '25 19:12

Nathan Tuggy