Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私が開発しているバイナリ PowerShell モジュールは、インストールされているマシンのディスク上の物理的な場所を知る必要があります。
Cmdletクラスから取得することは可能ですか?もしそうなら、どのように?
Cmdlet
すべての.NETアセンブリ(およびPowerShellバイナリモジュールは.NETアセンブリ)には、この情報を含むプロパティがあります。C#の場合:
var myPath = Assembly.GetExecutingAssembly().CodeBase;
また、スクリプトモジュール$PSScriptRootには、現在のスクリプトの場所があります。V3では、これはどのスクリプトでも設定されているように見えます。
$PSScriptRoot