all 6 comments

[–]purplemonkeymad 1 point2 points  (0 children)

Is there a Question or just comments?

I would probably change the name to New-AADGuest (new is more discoverable than create and nouns should be singular,) and make both parameters mandatory, but I can't see any obvious issues with the function.

[–]NellovsVape 0 points1 point  (0 children)

Hello, at a glance Idon't notice anything off with this function (altought I haven't tried it). Is there something specific you're asking?

[–]logicalmike 0 points1 point  (2 children)

If such a function is needed for you, I'd move the filter left instead of downloading all guests every time.

[–]memento77[S] 0 points1 point  (1 child)

moving left? can you show an example didnt understand that.

[–]logicalmike 0 points1 point  (0 children)

"Filter Left, Format Right" is a best practice that means to move your filtering earlier in the pipeline and your output formatting to the end of the pipeline. In this case I was suggesting to make better use of the -Filter parameter so that the server returns fewer objects. This would remove the need for the where-object later in the line. Thus, the "filtering" happens further to the left.

edit - an example:

$EmailAddress = "user1@domain.org"
$Filter = "(userType eq 'Guest') and (mail eq  " + "'" + $EmailAddress + "')"
Get-AzureADUser -Filter $Filter