Mar 1, 2010

Manage ASP.NET Providers with PowerShell

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” “” “Best Portal” “SharePoint”

List first 1000 users
PS> $provider | Get-MembershipUser –maxResult 1000



Bye, Christian


ArbutusJoe said...


I'm trying to use your PowerShell script (thanks for putting it together BTW.)

However, when I run it against a web.config file that I know is configured properly for a SharePoint web app that's using SqlMembershipProvider for FBA, I get "Unable to connect to SQL Server database". I know that the data connection is valid because FBA is otherwise working.

I think that it's finding an inherited provider, but not the configured provider.

Any hints?


ArbutusJoe said...

Followup to my previous query: it appears that the script can't find my provider by name. If I don't supply a name, it finds one called "AspNetSqlMembershipProvider"

Christian said...

Hi, it seems the script will fallback to the machine config. To read the web.config settings I switch the config file of the app domain. This just works if Shell hasn't read any config value before. Please check that you use the script in a fresh shell instance without any snapins that you don't need.
Bye, Christian

Web developer said...

Incredible points is found below using excellent content material, superb way with words-at all. I do not recognize how put it into practice but don’t stop! For those as if you occur on the internet.

Northfield Web Design said...

Let me test to see which language is to set up website.

Anonymous said...

Hello Christian,

I am facing same issue which rblitz has faced. My custom membership providers are not appearing in list.

What might be issue.

Can you plz help me out to resolve it.

Thanks Christian.

Anonymous said...

Same issue like the one of Suhil and rblitz.
And idea ?

Unknown said...

Thanks a bunch for sharing this with all people you actually recognize what you are talking about! Bookmarked. Kindly also discuss with my website.
Email list providers

Jameson Bozeman said...

After battling with getting my membership provider because the script didn't load my config path (resulting in "unable to connect to SQL Server database"). I found that once I ran this script from Windows Powershell (the blue one) everything worked. There must be some snapins in the SharePoint 2010 Management Shell that load other configs before the script can.

digital signature FAQ said...

Thank you so much for taking the time to share this information. A great read. I’ll certainly be back.

Chris said...

Regarding the "Unable to connect to SQL Server database" problem, this is because just changing the config file of current appdomain is not enough due to caching mechanisms in .NET -> you also need to "reset" the cache to force it to reload and take into account your new config file (more explanation here). You can do this in Powershell by using the following code (with help from here):

[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $appConfigPath )

$BindingFlags= [Reflection.BindingFlags] "NonPublic,Static"

$PrivateField = [System.Configuration.ConfigurationManager].GetField("s_initState",$bindingFlags)
$PrivateField.SetValue($null, "NotStarted" -as [Int])

$PrivateField = [System.Configuration.ConfigurationManager].GetField("s_configSystem",$bindingFlags)
$PrivateField.SetValue($null, $null)

$c = [System.Configuration.ConfigurationManager].Assembly.GetTypes() | Where-Object {$_.FullName -eq "System.Configuration.ClientConfigPaths"}
$PrivateField = $c.GetField("s_current",$bindingFlags)
$PrivateField.SetValue($null, $null)

Cheap Chanel Bags said...

I honestly don’t find this bag pretty. Yes for sure it is a special piece as it’s one of the latest collaborations of the fashion house with select artists/ designers

Russell Wright said...

I also appreciate the work Christian has done, but am also facing the issues others have reported. I'm using the Windows PowerShell ISE and have been struggling with this all day. I finally made changes in the machine.config so it has the values I've been trying to read in the web.config to get it to work. I've now proved it will work, but I'm baffled as to why [System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $appConfigPath ) will not read the Membership Provider data in the always falls back to the machine.config.

I guess I'll try it in the "non-ISE" environment to see if I get different results. I might also try what Chris recommended and try and reset the cache. Ugh!

Chris said...

Hi Russell,

I did have several problems also but forcing the cache to reload solved all these problems, give it a try !

Unknown said...

happy hug day 2016 SMS
hug day 2016 Wishes cards greetings
Hug day Date 2016
hug day sms said...

20160423 junda
air jordans
cheap oakley sunglasses
kate spade outlet
adidas stan smith
ray ban sunglasses
michael kors outlet
nike air max shoes
cheap omega watches
yeezy boost 350
michael kors outlet online
michael kors outlet online
nike free runs
air jordan uk
michael kors outlet online
pandora charms
ray ban outlet
calvin klein outlet
fitflops sale clearance
toms outlet
nike huarache white
sac longchamp
toms outlet
michael kors outlet clearance
bottega veneta outlet
armani watches
gucci handbags
nike blazer
oakley sunglasses
true religion jeans
cheap jordans
ray bans
bottega veneta handbags
jimmy choo outlet
oakley sunglasses
prada outlet
reebok shoes
true religion
burberry outlet

Unknown said...

20160426libinmichael kors outlet
cheap soccer jerseys
nike air max
ralph lauren uk
soccer jerseys wholesale
prada outlet online
cazal sunglasses
ralph lauren outlet
links of london
coach factory outlet
cheap nba jerseys
versace sunglasses
fitflops sale
michael kors outlet online
ralph lauren polo shirts
louis vuitton outlet online
kate spade handbags
coach handbags
michael kors handbags
ralph lauren uk
nhl jerseys
prada shoes
michael kors outlet store
hermes bags
michael kors uk
cheap nhl jerseys
ray ban sunglasses
lululemon outlet
cartier outlet
michael kors wallet
coach outlet online
true religion sale
louis vuitton handbags
lebron shoes
tiffany jewellery

رواد الحرمين said...

شركة كشف تسربات المياه بالاحساء
كشف تسربات المياه بالاحساء
شركة عزل اسطح بالاحساء
شركة عزل خزانات المياه بالاحساء
شركه عزل مائى بالاحساء
شركة عزل حرارى بالاحساء
شركة ترميم منازل بالاحساء
شركة مكافحة حشرات بالاحساء
شركة رش مبيدات بالاحساء
شركة تسليك مجارى بالاحساء
شركة ترميم منازل بالاحساء

Unknown said...

7.14lllllyuan"tiffany and co"
"michael kors outlet"
"hollister uk"
"michael kors outlet"
"salomon shoes sale"
"ralph lauren outlet"
"bottega veneta outlet online"
"fred perry polo"
"true religion jeans"
"michael kors outlet"
"camisetas futbol baratas"
"cartier outlet store"
"christian louboutin shoes"
"nike soccer shoes"
"polo ralph lauren"
"polo ralph lauren"
"michael kors outlet"
"longchamp handbags"
"fitflops sale"
"michael kors outlet"
"coach outlet online"
"louis vuitton handbags outlet"
"adidas shoes"
"tory burch shoes"
"chrome hearts eyewear"
"tory burch outlet"
"michael kors outlet"
"replica watches"
"burberry sunglasses on sale"
"louis vuitton bags"
"coach outlet"
"jordan shoes 2015"
"michael kors outlet"
"abercrombie outlet"

aboshady said...

شركة شراء اثاث مستعمل بالرياض
ارقام اثاث مستعمل بالرياض
محلات شراء الاثاث المستعمل بالرياض
محلات الاثاث المستعمل بالرياض

Fangyaya said...

michael kors purses
christian louboutin outlet
burberry handbags
coach outlet online
fitflop clearance
jordan 3s
michael kors
michael kors outlet
air jordan 8
replica rolex watches
adidas outlet store
michael kors outlet clearance
retro 11
cheap true religion jeans
cheap true religion
nike air max uk
replica rolex watches
christian louboutin shoes
supra footwear
louis vuitton bags
designer handbags
polo ralph lauren
cheap basketball shoes
adidas originals
coach outlet store online
coach outlet
cheap jordan shoes
oakley vault
jordan retro 4
coach factory outlet online
louis vuitton outlet
air jordan shoes
ed hardy outlet
gucci handbags
adidas yeezy
kobe shoes
discount jordans
cheap jordans
oakley sunglasses
coach factory outlet online

رواد الحرمين said...

شركة كشف تسربات المياه بالرياض
كشف تسربات المياه بالرياض شركة كشف تسربات المياه بالدمام
كشف تسربات المياه بالدمام شركة كشف تسربات المياه بالاحساء
كشف تسربات المياه بالاحساء
شركة كشف تسربات المياه بالجبيل
كشف تسربات المياه بالجبيل
شركة كشف تسربات المياه بالخبر
كشف تسربات المياه بالخبر
شركة كشف تسربات المياه بالقصيم
كشف تسربات المياه بالقصيم
شركة كشف تسربات المياه بالقطيف
كشف تسربات المياه بالقطيف

كشف تسربات المياه بالظهران
شركة كشف تسربات المياه بالظهران
شركة عزل اسطح بالاحساء
شركة عزل اسطح بالظهران
شركة عزل اسطح براس تنوره
شركة عزل حراري براس تنوره
شركة تسليك مجارى براس تنوره
شركة كشف تسربات المياه بالنعيرية
شركة كشف تسربات المياه بسيهات
شركة كشف تسربات المياه براس تنورة
شركة مكافحة النمل الابيض بالدمام

Unknown said...

cheap oakleys
ralph lauren pas cher
canada goose
michael kors outlet clearance
true religion outlet
armani exchange
gucci outlet
ed hardy
ugg boots
ray ban sunglasses

Paulo said...

Understudy advances for understudy with awful credit are the ideal answer for a credit issue. How about we investigate what kind of terrible credit understudy advance choices you have. Payday Loans San-diego

raybanoutlet001 said...

cheap ray ban sunglasses
nike trainers
los angeles lakers jerseys
ugg outlet
true religion outlet store
nike air force 1
ugg boots
kate spade outlet
oakley sunglasses
fitflops shoes

Best Construction Company City of Yonkers said...

The team at Ajrin Construction Inc. is the best of the best general contractors and support staffs, as selected from within the industries over City of Yonkers NY based upon their achievements and their understanding of complex projects.
Best Construction Company City of Yonkers

قمم التميز said...

شركة مكافحة حشرات بخميس مشيط
مكافحة النمل الابيض بخميس مشيط
شركة نقل عفش بخميس مشيط

anosh said...

شركة مكافحة حشرات بجازان
شركة مكافحة حشرات بالطائف

Garrick Co Ida said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

check cashing said...

It is terribly arduous to say once exactly ought to be compelled to cash your check. typically it's reaching to really hard to cash if it isn't official hours. That’s why we tend to tend to feel you superabundant and twenty four hour check cashing services.
check cashing

bathroom remodeling contractor yonkers said...

Ajrin Construction Inc. is a privately owned firm and has been providing bathroom remodeling services to clients all across the boroughs of County NY.
bathroom remodeling contractor yonkers

Unknown said...

2018120 leilei3915
michael kors outlet online
true religion outlet online
vintage nhl jerseys
mulberry handbags
uggs outlet
coach outlet
adidas superstar shoes
jordan retro shoes
michael kors outlet
cheap ugg boots

khairy said...

شركة تنظيف سجاد بابها
شركة تنظيف موكيت بابها
شركة عزل اسطح بابها
شركة تسليك مجاري بابها
شركة تنظيف مساجد بابها
شركة تنظيف وصيانة مسابح بابها
شركة تنظيف الاثاث بابها
شركة تنظيف ستائر بابها
شركة جلي بلاط بابها

raybanoutlet001 said...

kate spade outlet online
oakland raiders jerseys
kate spade outlet online
ralph lauren uk
kate spade outlet online
louboutin shoes
nike factory outlet
moncler outlet
ralph lauren outlet
jacksonville jaguars jersey

chenlili said...

pandora charms
coach outlet store online
ferragamo outlet store
ray-ban sunglasses
christian louboutin shoes
longchamp handbags
pandora charms outlet
fitflops sale clearance
fred perry polo
coach outlet online

Unknown said...

20180601 junda
nuggets jerseys
canada goose jackets
wizards jerseys
ugg outlet
longchamp outlet
ugg outlet
fred perry polo shirts
polo ralph lauren
birkenstock outlet
g-star jeans

Unknown said...

polo ralph lauren
polo ralph lauren
moncler outlet
ralph lauren outlet
pandora outlet
ray ban eyeglasses
coach factory outlet
christian louboutin outlet
adidas outlet online

Unknown said...

2018914 leilei3915
pandora charms
louboutin shoes
adidas nmd r2
michael kors outlet
michael kors outlet online
michael kors
oakley sunglasses wholesale
oakley sunglasses wholesale
coach factory outlet
coach factory outlet

5689 said...

new balance shoes
bottega veneta
nike shoes
moncler outlet
nba jerseys
christian louboutin outlet
fitflops clearance
canada goose outlet
adidas outlet
longchamp outlet

5689 said...

hogan shoes
coach outlet
christian louboutin shoes
nike shoes
canada goose
canada goose jacket
salomon shoes
ralph lauren polo
canadian goose
pandora outlet

Cara Efektif Mengobati Infeksi Paru said...

Articles that are very dancing to read, are very helpful and thank you for sharing the information

Tips Pengobatan Tulang Keropos
Obat Untuk Menghilangkan Penebalan Dinding Rahim
Cara Mengobati Polip Rahim Tanpa Operasi
Pengobatan Limpa Bengkak Tanpa Operasi
Cara Mengobati Ulu Hati Terasa Sakit
Obat Alami Untuk Menghilangkan Benjolan Di Payudara

Ajith said...

Great Post,really it was very helpful for us.
Thanks a lot for sharing!
I found this blog to be very useful!!
PowerShell Scripting training in Bangalore

al ghadeer said...

شركة عزل اسطح شينكو جنوب الرياض
شركة عزل اسطح شينكو غرب الرياض
شركة عزل اسطح شينكو بالخرج
شركة عزل اسطح شينكو شرق الرياض
شركة عزل اسطح شينكو شمال الرياض
شركة عزل اسطح شينكو بالرياض

al ghadeer said...

شركة عزل فوم بالمدينة المنورة
شركة عزل فوم بالدمام
شركة عزل فوم بالخبر
شركة عزل فوم بالجبيل
شركة عزل فوم بالقطيف

شركة عزل فوم بالاحساء
نتيجة الثانوية العامة 2019

شركة عزل فوم