1

I have a cmdlet under module M1. I need to run the cmdlet from commandline itself. Like say, powershell -Command cmdlet1.

But I need to import module M1 before running cmdlet1. Is there a way I can do this in one shot?

I don't want to interact with PowerShell, but I want to run cmdlet1 just like I would run a normal Windows command.

1 Answer 1

3

Try:

 powershell -command "& { import-module M1; cmdlet1 }"

Or just:

 powershell -command "import-module M1; cmdlet1 "
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.