Sitecore EXM
0 0
Read Time:57 Second
Sometimes we might need to clear old users / specific domain users. We can do this job from the Sitecore User Manager and remove them one by one. But if the number of users is more then it will be a tedious job. We can do it in bulk using a SQL script or a Powershell script to remove Sitecore users.

PowerShell script should be the first choice:
Get-User -Filter * | Where-Object {$_.Profile.Email -like "*@gmail.com"} | Remove-User

SQL script as the second option:

Select UserId Into #TempUserList
From [www-s9-uat7-xp1_Core].[dbo].[aspnet_Membership]
Where Email Like '%@gmail.com'

Delete From [www-s9-uat7-xp1_Core].[dbo].[aspnet_UsersInRoles]
Where UserId in (Select UserId From #TempUserList)

Delete From [www-s9-uat7-xp1_Core].[dbo].[aspnet_Membership]
Where UserId in (Select UserId From #TempUserList)

Delete From [www-s9-uat7-xp1_Core].[dbo].[aspnet_PersonalizationPerUser]
Where UserId in (Select UserId From #TempUserList)

Delete From [www-s9-uat7-xp1_Core].[dbo].[aspnet_Profile]
Where UserId in (Select UserId From #TempUserList)

Delete FROM [www-s9-uat7-xp1_Core].[dbo].[aspnet_Users]
Where UserId in (Select UserId From #TempUserList)
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Previous post Filter user by domain in Sitecore User Manager
Sitecore EXM Next post Sitecore 9 Experience profile common error

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *