Tag Archives: user accounts

Permanently delete users from Office 365

When you delete user accounts from Office 365 (en thus Azure Active Directory) these accounts are not permanently deleted, but they are kept in a Deleted Users container for 30 days. This is not only true for cloud users that are deleted in the Microsoft Online Portal, but also for synced users that are deleted in your on-premises Active Directory.

clip_image002

Although you can see the deleted users in the Microsoft Online Portal, there’s no way to permanently delete them here.

The solution is to use the Azure Active Directory Module for PowerShell, using PowerShell you can actually permanently delete these user account.

To retrieve a list of all users in the Deleted Users container open Azure Active Directory PowerShell and execute the following command:

Connect-MSOLService
Get-MsolUser -ReturnDeletedUsers

clip_image004

To permanently remove these user accounts you can use the same command, but pipe the output of the command into the Remove-MsolUser -RemoveFromReclycleBin command. You can add the -Force option to bypass the confirmation of each user deletion (i.e. the ‘Are you sure? Yes[y], No[n]’ message).

clip_image006

Now when you execute the Get-MsolUser -ReturnDeletedUsers command you’ll see the all users are permanently removed.

Please be careful, once permanently removed there’s no way to restore the user accounts!

Manage users in Office 365 using PowerShell

After you’ve add domains to your Office 365 environment (using PowerShell of course) you might want to add users as well. In this blog post I’ll discuss how to add users, add and change licenses, remove users and change password settings.

Add Users using PowerShell

Use the Get-MsolUser command to get an overview of all users in Azure Active Directory (these were created in an earlier blog post):

image

And use the Get-MsolAccountSku command to see what license is available:

image

When creating a new user in Azure Active Directory you can use the New-MsolUser command, combined with the results of the Get-MsolAccountSku command for the license information. You can use the –LicenseAssignment and –UsageLocation options to assign a proper license.

New-MsolUser -UserPrincipalName Santa@office365labs.nl -FirstName Santa -LastName Klaus -DisplayName 'Santa Klaus' -Password 'Pass2015' –ForceChangePassword:$TRUE -LicenseAssignment "inframan:ENTERPRISEPACK" -UsageLocation NL

image

Continue reading Manage users in Office 365 using PowerShell