Skip to content

Instantly share code, notes, and snippets.

@meadhikari
Created February 20, 2015 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meadhikari/a677fa835ee3b73a3d3f to your computer and use it in GitHub Desktop.
Save meadhikari/a677fa835ee3b73a3d3f to your computer and use it in GitHub Desktop.
Powershell script to deactivate user who have not logged in for 30 days
$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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment