1

I'm trying to find out using C# if MSOnline PowerShell module is available at OS.

From the first look - nothing difficult. We can invoke PowerShell methods from C#. But for some reason all code snippets I tried to use do not get result with MSOnline module.

For example we use method http://www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C and pass command like:

Get-Module -ListAvailable -Name (here is the name)

So if we run it for TLS module - it works fine. On the picture below we see how it works in C# console application and on the right - how it looks in PowerShell. Looks fair.

enter image description here

But everything changes if we try to lookup MSOnline module:

enter image description here

As we see - C# program gives no results, while PowerShell itself shows us that module is available.

I'm really confused. I thought that is something with my PC, but I have checked on some different ones including Server 2012 R2. Result is the same - this module can not be looked up via C# even if we use exactly the same command as in PS.

Has anyone seen such problem? If yes - what solution can be done to detect via C# if MSOnline PS module is present.

Thank you.

1 Answer 1

1

Actually I found a solution for my own question:

You need to make sure that your program and module has both 32 or 64 bits.

MSOnline is running x64 and if your programm is targeting 32 bit system or has Any CPU and runs 32 bits during runtime - you will get zero result.

That's it.

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.