简体   繁体   English

在二进制Powershell模块中获取工作目录

[英]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. 我正在用C#编写二进制Powershell模块,但似乎找不到从命令中获取当前工作目录的方法。

My first thought was to do a simple Directory.GetCurrentDirectory(); 我首先想到的是做一个简单的Directory.GetCurrentDirectory(); from the System.IO library but it only seems to give me the directory that powershell was launched in. System.IO库中获取,但似乎只给了我启动powershell的目录。

How can I get the current directory within a binary powershell module during a command execution? 在执行命令期间,如何在二进制Powershell模块中获取当前目录?

Thanks 谢谢

假设您的cmdlet使用CurrentProviderLocation("FileSystem").ProviderPath从PSCmdlet派生。ProviderPath应该可以很好地完成此工作(未经测试)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM