Skip to content

Instantly share code, notes, and snippets.

@JustinGrote
Last active October 22, 2021 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustinGrote/02ac004ace5884cc97d8094ab0a92ff4 to your computer and use it in GitHub Desktop.
Save JustinGrote/02ac004ace5884cc97d8094ab0a92ff4 to your computer and use it in GitHub Desktop.
Better Example of using classes
using namespace Microsoft.Graph.PowerShell.Models
[MicrosoftGraphUser1]@{
DisplayName = 'Some User'
UserPrincipalName = 'someuser@mycompany.com'
MailNickname = 'someuser@mycompany.com'
AccountEnabled = $true
PasswordProfile = [MicrosoftGraphPasswordProfile]@{
Password = 'Pass@word1'
}
} | New-MgUser
@JustinGrote
Copy link
Author

The pipeline works simply because -BodyParameter accepts pipeline input by Value, and since it is typed, it is easy to discover over the other parameter sets.

    -BodyParameter <IMicrosoftGraphUser1>
        Represents an Azure Active Directory user object.
        To construct, see NOTES section for BODYPARAMETER properties and create a hash table.

        Required?                    true
        Position?                    named
        Default value
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment