Skip to content

msonline module - where statements not working #644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Shadoxity opened this issue Jun 14, 2021 · 5 comments
Closed

msonline module - where statements not working #644

Shadoxity opened this issue Jun 14, 2021 · 5 comments
Assignees

Comments

@Shadoxity
Copy link

Hey Team,
I am trying to get a script working but any time I pipe a "where" or "Where-object" into it, I get zero results.

i.e.
$UserNames = Get-MsolUser -TenantId $tenantid -ALL | Where {($_.licenses).AccountSkuId -ilike "*$($licenseName)"} | Sort-Object DisplayName

If i run the same script locally it works perfectly fine, but just does not work in functions.
If i remove the Where statement it runs fine.

Please help

@Francisco-Gamino
Copy link
Contributor

Hello @Shadoxity -- Thank you for reporting this issue. Are you importing the module using the -UseWindowsPowerShell ?

@Shadoxity
Copy link
Author

Yes, definitely.
The module doesnt work unless you do that.

I am wondering if its something to do with "deserialized" objects. as it says this when importing the module.
Module msonline is loaded in Windows PowerShell using WinPSCompatSession remoting session; please note that all input and output of commands from this module will be deserialized objects.

and some more digging I have found the licenses property returns.
"Licenses": [

"Microsoft.Online.Administration.UserLicense"

],

Instead of the actual license names :S
.
So I am not sure where to go from here. I cannot use the azuread module cause it does not work with the partner center delegated admin like it should.
But I need a solution to get this into azure functions asap.

@Francisco-Gamino
Copy link
Contributor

Thanks for the reply @Shadoxity.

There is another potential workaround you can try which uses the Windows PowerShell version in the worker (this is the VM where your function code is executed).

The workaround is described here: #232 (comment).

Here is a full example: https://github.com/eamonoreilly/ManageAzureActiveDirectoryWithPowerShellFunction/blob/master/ManageAzureAD/run.ps1

@Shadoxity
Copy link
Author

Great idea, and it seems to work! Just need to work out getting the right output from it!
Genius! Thanks so much for sharing that, that will get me out of trouble for now.

@Francisco-Gamino
Copy link
Contributor

Great to hear the workaround is working. I will follow-up with the PowerShell Team on the serialization issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants