Pages

Friday, September 11, 2015

Remove specific user from All Site collections in office 365 Tenant

 

Finally I got below script to remove user from all site collections in office 365 Tenant J

$credential = Get-Credential

$Adminurl = "https://XXXXX-admin.sharepoint.com"

Connect-SPOService -url $Adminurl -credential $credential

write-host "Connected" -foregroundcolor green

$sites = get-sposite

Foreach ($site in $sites)

{

Write-host "Removing users to $($site.URL)" -foregroundcolor yellow

Remove-SPOUser -Site $site.url -LoginName user@yourdomain.com

}