This project has moved. For the latest updates, please go here.

Deactivate Inactive(not logged in for 60 days) user

Feb 19, 2015 at 3:06 PM
Hi

I want to deactivate FBA user who have not logged in for the last 60 days. How would I achieve this please help. I see "Last Login" listed in FBA User managment page but how do I access this information from powershell so that I could deactivate account older than 60 days

Thanks
Coordinator
Feb 19, 2015 at 6:55 PM
You should be able to deactivate the user directly from the user management page.

I assume you want to do it through powershell to automate it? If so, you can probably use the following script as a base to do what you need:

http://www.ilovesharepoint.com/2010/03/manage-aspnet-providers-with-powershell.html
Feb 20, 2015 at 2:41 PM
Edited Feb 24, 2015 at 4:12 AM
Thanks I ended up writing a script. Posting it here if some other may need it.
$connection = new-object System.Data.SqlClient.SQLConnection("Data Source=.;Integrated Security=SSPI;Initial Catalog=aspnetdb");
$cmd = new-object System.Data.SqlClient.SqlCommand("UPDATE dbo.aspnet_Membership SET IsApproved = 0 where LastLoginDate  < DATEADD(DAY, -30, GETDATE())", $connection);
$connection.Open();
$reader = $cmd.ExecuteNonQuery()
$connection.Close();
Write-output $reader