Sharepoint 2010 – Delete all users’ personel sites via powershell
03/10/2011 Leave a comment
#PowerShell Script - Delete All Users Personel Sites - SharePoint 2010 #The scripts is distributet "as-is." Use it on your own risk. The author give no warranties, guarantees or conditions. #Add SharePoint PowerShell SnapIn if not already added if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } [Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") $mysiteHostUrl = "http://my" $mysite = Get-SPSite $mysiteHostUrl $context = [Microsoft.Office.Server.ServerContext]::GetContext($mysite) $upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) $AllProfiles = $upm.GetEnumerator() foreach($profile in $AllProfiles) { $DisplayName = $profile.DisplayName $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value if($profile.PersonalSite -ne $Null) { $profile.PersonalSite.Delete() write-host $AccountName , " personel site deleted successfully" } } $mysite.Dispose();