2

I'm using code on http://code.msdn.microsoft.com/office365/Office-365-Manage-users-by-cfc96d5e to connect to Office 365 via a test c# web application which basically connects to azure active directory and tries to execute couple of powershell cmdlets.

I'm getting this exception on the Pipeline.Invoke method on the Connect-MsolService cmdlet in my web app:

Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown.

So far:

  • Followed instructions on this KB article: http://support.microsoft.com/kb/2494043
  • Installed/enabled the required software (NET Framework 3.5, Microsoft Online Services Sign-In Assistant (64 bit), Microsoft Online Services Module for Windows PowerShell (64 bit))
  • set-executionpolicy remotesigned
  • using non-federated primary admin account in office cloud to connect remote powershell
  • Using a Windows 2008 R2 64 bit machine.
  • Targeting 64 bit processor in VS, and .NET framework 4.0
  • IIS apppool for this web application is set to use .NET framework 4.0

I can successfully execute connect-msolservice and run cmdlets using the Microsoft Online Services Module for Windows PowerShell on the same machine, using same account.

What else can I try?

Kara
  • 6,115
  • 16
  • 50
  • 57
joym8
  • 4,014
  • 3
  • 50
  • 93
  • What's the Message within the exception? – vonPryz May 24 '13 at 19:51
  • vonPryz, this is actually the Message property of the exception: Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown – joym8 May 25 '13 at 00:29

1 Answers1

5

Change IIS App Pool setting Load User Profile to True

http://community.office365.com/en-us/forums/172/p/165426/474632.aspx#474632

joym8
  • 4,014
  • 3
  • 50
  • 93
  • Thank you for coming back and posting the answer! – davidmdem Jul 09 '13 at 21:13
  • So this solved the issue for me, however, now the commands seem to just fail silently. For example, Set-MsolUser -UserPrincipalName "{username}" -UsageLocation "US" doesn't have any errors, but doesn't actually do anything. When I run the same command directly in powershell it works. Any ideas? – Andrew Sep 15 '16 at 05:01
  • on top of my head I'd say step into the code (F11 in VS) and inspect your variables? or add a watch? sorry not sure what else you can try. maybe post your question in msoffice forum http://answers.microsoft.com/en-us/msoffice/forum/mso_manage – joym8 Sep 16 '16 at 17:07