Programmatically delete users from all site collections
-
Please guys, I need a help on the code that programmatically deletes outgoing SharePoint users from all site collections in SharePoint 2010. Thank you all..
beluomo
-
Please guys, I need a help on the code that programmatically deletes outgoing SharePoint users from all site collections in SharePoint 2010. Thank you all..
beluomo
You can achieve this using the PowerShell script , like as bellow. hope it will help you $LoginName = "domain\login" $siteURL = "http://SharePointSiteURL" #URL to any site in the web application. Clear-Host $siteCount = 0 [system.reflection.assembly]::loadwithpartialname("Microsoft.SharePoint") $site = new-object microsoft.sharepoint.spsite($siteURL) $webApp = $site.webapplication $allSites = $webApp.sites foreach ($site in $allSites) { $web = $site.openweb() $web.SiteUsers.Remove($LoginName) $web.Dispose() $siteCount++ } $site.dispose() write-host "Updated" $siteCount "Site Collections."