I’ve written this script to manage SQL users on a SharePoint box with form based security (FBA).
Load the script
PS>. .\Manage_ASP_NET_Providers.ps1 “C:\..\web.config”
You have to provide the path to the web.config which contains the membership provider configurations.
The script will change the current app domain’s config path and then loads the System.Web Assembly. The sequence is important. If you want to change app config path later, you have to restart PowerShell and load the script again with another path.
Get Membership Provider “sqlMembers”
PS> $provider = Get-MembershipProvider “sqlMembers”
Add a new user (login, mail, question, answer)
PS> $provider | Add-MembershipUser “cglessner” “firstname.lastname@example.org” “Best Portal” “SharePoint”
List first 1000 users
PS> $provider | Get-MembershipUser –maxResult 1000