3

My coworker and myself I am facing a really odd issue with PowerShell ISE: The following code simply returns $null when executed via PowerShell ISE, but works fine in a regular PowerShell window or in VS Code:

Import-Module AzureAd

Connect-AzureAD

$user = Get-AzureADUser -SearchString "fooar@test.com"

The connection is correctly established because calling Get-AzureADUser -All $true returns the expected set of users in ISE.

We are using version 2.0.0.155 of module AzureAD. And this is the used PowerShell version:

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      16299  248

Any idea why it is not working in ISE?

thuld
  • 680
  • 3
  • 10
  • 29
  • Perhaps, STA vs MTA model difference. Does it work for you when you start powershell via `powershell -sta`? – tukan Mar 09 '18 at 12:25
  • I am getting the same behavior as described: PowerShell works, ISE doesn't. Same version of PowerShell, but `2.0.0.131` of the AzureAD module. Also, when checking `$Host.Runspace.ApartmentState` both were in STA. – beavel Mar 09 '18 at 12:34
  • Ok, last least is it not only me an my co-worker. – thuld Mar 12 '18 at 06:17
  • Same problem with AzureAD 2.0.1.16. Super odd. In addition, using searchstring for just `foobar` but not `foobar@example.com` – Mark Mascolino Mar 15 '19 at 18:51

0 Answers0