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
Assuming your cmdlet derives from PSCmdlet, using
CurrentProviderLocation("FileSystem").ProviderPath
should do the job nicely (untested).