Saturday, 15 August 2015

c# - Error while Trying to load Powershell Module "MSOnline" in ASP.NET web app -



c# - Error while Trying to load Powershell Module "MSOnline" in ASP.NET web app -

good morning have 1 problem trying o load powershell module called msonline in asp.net after next links: http://www.msdigest.net/2012/03/how-to-connect-to-office-365-with-powershell/ http://blogs.technet.com/b/educloud/archive/2013/01/23/managing-office-365-for-education-using-powershell.aspx

this button run script via code behind in c#. when trying load module threw exception.

protected void bexecute_click(object sender, eventargs e) { // import-module msonline seek { //loading msonline using initialsessionstate initialsessionstate iss = initialsessionstate.createdefault(); iss.importpsmodule(new string[] { "msonline" }); //before solution iss has exception of "not found" msonline module //create runspace runspace test = runspacefactory.createrunspace(iss); //open runspace test.open(); //create pipeline pipeline pipeline = test.createpipeline(); //create stringbuilder append script stringbuilder script = new stringbuilder(); //take script tscript (textboxt id="tscript" in default.aspx script.appendline(@"get-module -listavailable"); //add script , commands pipeline; pipeline.commands.addscript(script.tostring()); //execute script , psobject results collection collection<psobject> resultobjects = pipeline.invoke(); //close runspace test.close(); if (resultobjects.count > 0) { /*** psobjects ***/ } } grab (system.management.automation.runtimeexception ex) { status.appendline(ex.message); } }

what need wrong. referenced system.management.automation (dll). don't have clue why not listed if it's installed it. give thanks help.

i have found msonline .dll files in : c:\windows\system32\windowspowershell\v1.0\modules\msonline if tried add together manually visual studio says "that msonline doesn't exist". quite weird, because have same permissions folder. what's going on! :s frustrating...

to asp.net web app run under x64 bit architecture should this:

1, ms online services assistant needs downloaded , installed microsoft online services sign-in assistant – 64 bit version http://go.microsoft.com/fwlink/?linkid=236300

2.ms online module powershell needs downloaded , installed microsoft online services module windows powershell (64-bit version) http://go.microsoft.com/fwlink/?linkid=236297

after step can run: get-module -listavailable , module msonline listed. still not working on 64 bits sos. original poster used win8 64bits , using win 8.1 64 bits , works well.

copy msonline module folder (path1) (path2) where

(path1) -> "c:\windows\system32\windowspowershell\v1.0\modules\msonline"

and

(path2) -> "c:\windows\syswow64\windowspowershell\v1.0\modules\msonline"

considering i'm running on vs2013 under windows 8.1 , 64 bits arquitecture.

after doing msonline module listed in get-module -listavailable (from webapp, not powershell)), import , utilize it.

c# asp.net powershell module office365-apps

No comments:

Post a Comment