Home > Office365 > Windows PowerShell cmdlets for Office 365 ~ Manage Users – Part 03

Windows PowerShell cmdlets for Office 365 ~ Manage Users – Part 03


This is the third article of the Manage Users article series. Herewith I have shown you more PS comdlets you can you use to manage users on Office 365. I always prefer to use PS comdlets to manage the O365 functions it makes my life easier. Most of the stuff can be done which I can not accomplish through the GUI Smile.

In below article I will cover how to

  1. Remove Msol Users.
  2. Remove Users from the Online Recycle Bin.
  3. Remove unlicensed users.


The Remove-MsolUser cmdlet is used to remove a user from the Microsoft Online directory. This cmdlet will delete the user, their licenses, and any other associated data.

I’ll be removing Adam Perera Msol user from the directory. This user assigned with all license services.




Remove-MsolUser –UserPrincipalName adam@valakulu.net




~Remove Users from the Online Recycle Bin~

Here we go we have we have remove a Msol user from the subscription. But this accounts will stick around for 30 days in recycle bin and there’s nothing you can do. If you want to remove the Msol user permanently you have follow below steps. Before going ahead with that will get list of deleted users in the Recycle Bin. You can use the below PS Cmdlets to retrieve the values of UserPrincipalName, objectID   ,

Get-MsolUser –ReturnDeletedUsers | select UserPrincipalName, objectID 



You can use –RemoveFromRecycleBin parameter to delete Msol user permanently with out waiting for 30 days to be automatically deleted from the subscription. But I need to mention one another thing if you want to get –RemoveFromRecycleBin parameter you have to install the latest version of Msol Powershell toolkit which available in below URL’s.

Then you can connect to the Online subscription and carry out the user deletion.

Remove-MsolUser -RemoveFromRecycleBin –ObjectId OBJECTID



Once you done with removing user and run the Get-MsolUser –ReturnDeletedUsers | select UserPrincipalName, objectID you will see the removed user is actually removed from the online recycle bin. Smile. If you still want to do a bulk deletion you have to write a separate PS script to achieve it.


~Remove unlicensed users~

You can retrieve all the Msol users with User Principal Name, Display Name and License Status by using below comndlet,



As you can see above Gill Christ’s License status is False, so we will see how to delete this Unlicensed users by using PS Cmdlet,

Get-MsolUser -all | Where-Object {$_.isLicensed -ne "true"}| Remove-MsolUser -Force




Windows PowerShell cmdlets for Office 365 ~ Manage Users – Part 01

Windows PowerShell cmdlets for Office 365 ~ Manage Users – Part 02

Categories: Office365
  1. October 3, 2012 at 1:03 pm

    I got this web site from my friend who told me concerning this web
    page and now this time I am visiting this website
    and reading very informative articles at this place.

  2. October 3, 2012 at 4:59 pm

    Very good post. I am experiencing many of these issues
    as well..

  3. October 7, 2012 at 9:31 pm

    Hey would you mind sharing which blog platform you’re using? I’m looking to start my own blog in the near future but I’m having a hard time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I’m looking for something completely unique.
    P.S My apologies for being off-topic but I had to ask!

  4. August 10, 2013 at 10:59 am

    Your style is so unique in comparison to other people I have
    read stuff from. Many thanks for posting when you have the opportunity, Guess I will just book mark this web site.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: