Add new guest user to azure powershell command

To add a new guest user to Azure using PowerShell, you can use the following command:

New-AzADUser -DisplayName "New Guest User" -UserPrincipalName "newguestuser@<tenant_name>.onmicrosoft.com" -MailNickname "newguestuser" -AccountEnabled $true -MailEnabled $true -UsageLocation "US" -Force

Replace <tenant_name> with the name of your Azure Active Directory (AAD) tenant.

Here's a breakdown of the parameters:

Once you run this command, the new guest user will be created in your Azure AD tenant. Note that guest users are not assigned to any Azure AD groups by default, so you may need to add them to a group manually using the Add-AzADGroupMember cmdlet.

Here's an example of how to add the new guest user to a group:

Add-AzADGroupMember -GroupObjectId <group_object_id> -MemberObjectId (Get-AzADUser -UserPrincipalName "newguestuser@<tenant_name>.onmicrosoft.com").ObjectId

Replace <group_object_id> with the object ID of the Azure AD group you want to add the user to.