1

The binary PowerShell module I'm developing needs to know its physical location on disk at the machine it is installed on.

Is it possible to get it from the Cmdlet class? If so, how?

1 Answer 1

2

Any .NET assembly (and a PowerShell binary module is a .NET assembly) has properties contains this information. In C#:

var myPath = Assembly.GetExecutingAssembly().CodeBase;

Also in a script module $PSScriptRoot is the location of the current script; in V3 this appears to be set in any script.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.