Connect to Azure AD
Azure AD PowerShell Modunle
You need install MSOnline module only once. In the next time, run to connect to Azure AD PowerShell.
##Connect to MSOnline
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;
Install-PackageProvider -Name NuGet -Force;
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted;
Install-Module -Name MSOnline;
Connect-MsolService;
##Delete users
Import-Csv "C:\Temp\Users.csv" |
ForEach { Remove-MsolUser -UserPrincipalName $_.UserPrincipalName -Force }
How do you now this worked
Get-MsolUser -ReturnDeletedUsers
Permanently Remove Deleted Users from Office 365
Get-MsolUser -ReturnDeletedUsers |
Remove-MsolUser -RemoveFromRecycleBin -Force
5/5 - (1 vote)