Archivo

Entradas Etiquetadas ‘remove users’

Add or Remove Office365 users via PowerShell

miércoles, 13 de marzo de 2013 Sin comentarios

Cambiar-idioma-esp

 

logo-powershell

In order to Add or Remove Office365 users using PowerShell, we must hace our environment ready to use with PowerShell and connect with Office365.

Once this is done, we can proceed…

Add Users:

We must have available licenses on our subscription if we want to assign one, if this is not the case, then we must Access to our Office365 Administration portal and buy some.

  • Log in to our office365 using powershell.
  • Run the following command to create the user:

New-MsolUser -UserPrincipalName a.lopez@contoso.com -DisplayName “Antonio Lopez – Contoso Ltd.” -FirstName “Antonio” -LastName “Lopez

  • Specify the location of the user (in this case, Spain)

Set-MSOLUser –UserPrincipalName a.lopez@contoso.com –UsageLocation ES

  • Assign a license to the recently created user with the following Cmdlet

Set-MsolUserLicense -UserPrincipalName a.lopez@contoso.com -AddLicenses “tenantname:AccountSKUId”

Where “tenantname” will be in our case “contoso” and “AccountSKUId” will be the plan we wish to assign. The available AccountSKUId are:

K1: SHAREPOINTDESKLESS EXCHANGE_S_DESKLESS

K2: SHAREPOINTWAC SHAREPOINTDESKLESS EXCHANGE_S_DESKLESS

P1: MCOLITE SHAREPOINTLITE EXCHANGE_L_STANDARD

E1: MCOSTANDARD SHAREPOINTSTANDARD EXCHANGE_S_STANDARD

E3: OFFICESUBSCRIPTION MCOSTANDARD SHAREPOINTWAC SHAREPOINTENTERPRISE EXCHANGE_S_ENTERPRISE

E4: OFFICESUBSCRIPTION MCOSTANDARD SHAREPOINTWAC SHAREPOINTENTERPRISE EXCHANGE_S_ENTERPRISE

A2: SHAREPOINTWAC_EDU MCOSTANDARD SHAREPOINTSTANDARD_EDU EXCHANGE_S_STANDARD

Besides, we can run the following cmdlet to determine the AccountSKUId used on our Office365

Get-MsolAccountSku | Format-Table AccountSkuId, SkuPartNumber

Note: if we want to do a license upgrade to a selected user, we must first remove the assigned license and then assign the new one.

To remove a license to a user, run the following:

Set-MsolUserLicense -UserPrincipalName a.lopez@contoso.com -RemoveLicenses “tenantname:AccountSKUId

Remove a User:

Simply run the following Cmdlet:

Remove-MsolUser -UserPrincipalName a.lopez@contoso.com

This will move the user to the «Deleted Mailboxes» área because it´s not a HardDelete…

Until next post….