Created
February 20, 2015 09:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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