# Import required module
Import-Module Microsoft.Graph.Identity.DirectoryManagement
# Get the list of users from a CSV file
$users = Import-Csv -Path "C:\temp\books.csv"
# Loop through each user and soft delete
foreach ($user in $users) {
Remove-MgUser -UserId $user.UserPrincipalName
Write-Output "Soft deleted user: $($user.UserPrincipalName)"
}
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article