Reputation: 615
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
Upvotes: 3
Views: 838
Reputation: 2244
Assuming your cmdlet derives from PSCmdlet, using CurrentProviderLocation("FileSystem").ProviderPath
should do the job nicely (untested).
Upvotes: 3