Get working directory in binary powershell module

810 Views Asked by At

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

1

There are 1 best solutions below

2
On BEST ANSWER

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