8

I need help with a problem I've been trying to solve for a week.

I have a PowerShell script that returns a list os users from Office365 environment.

If I run the script from my PowerShell console (my machine), the script returns the expected data. If I run the script from Server (W2008 R2 SP1) PowerShell console, the script returns the expected data. If I debug my C# WebService code (from where script is executed) in my machine, the srcipt returns the expected data.

PROBLEM: If I call to the WebService hosted into the Server, the script returns NOTHING.

Code:

RunspaceConfiguration runspcConfig = RunspaceConfiguration.Create();
Runspace run = RunspaceFactory.CreateRunspace(runspcConfig);
run.ApartmentState = System.Threading.ApartmentState.STA;
run.ThreadOptions = PSThreadOptions.UseCurrentThread;
run.Open();
Pipeline pipeline = run.CreatePipeline();
Command cmd = new Command("PathScript.ps1");
cmd.Parameters.Add(new CommandParameter("DOMAIN", "domain.onmicrosoft.com"));
cmd.Parameters.Add(new CommandParameter("PRODUCT", "productReference"));
pipeline.Commands.Add(cmd);
Collection<PSObject> users=pipeline.Invoke();

Finally found the error: The type initializer for 'Microsoft.Online.Administration.Automation.ConnectMsolService' threw an exception.

The user and password are right, IUSR and "ApplicationPool user" are included in Administrator group.

Any idea?

3
  • 2
    If you want help with your code you first need to show your code. Commented Sep 23, 2013 at 12:00
  • @user2806842 It is OK to answer your own question. Commented Sep 29, 2013 at 20:13
  • 3
    please add your solution as an answer and accept it. Commented Oct 7, 2013 at 19:30

1 Answer 1

2

By OP,

Problem solved: "Load User Profile" to true in IIS application pool advanced settings

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.