I am trying to use powershell to create FBA users instead of entering them from the 'FBA User Management' page.
The following script adds the user to sharepoint and in the correct group, but they do not end up in the FBA aspnet membership database and therefore do not show up on the 'FBA User Management' page.
It should be added to the membership database before adding it to SharePoint. I didn't find any examples of doing it in PowerShell, however you should be able to take the code from here
and convert it to PowerShell, using the New-Object cmdlet. It would probably make for a good blog post if you work it out. I'm not sure where you'd specify the membership provider though, unless you put it in machine.config.
I have done this and it is simple enough. The key to PowerShell is that its the environment you use to run it that controls the configuration so:
This caught me on the hop as I tend to develop scripts in PowerGUI but sysops tend to just use PowerShell to run them. Thus it worked on my dev box but failed in operations.
If you use PowerShell from the command line you need to add your membership config to: %windir%\System32\WindowsPowerShell\v1.0\PowerShell.exe.config
If you use the Windows PowerShell ISE then its: %windir%\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe.config
If you use PowerGUI then its: C:\Program Files (x86)\PowerGUI\PowerGUI.exe.config
I am really struggling with this. Maybe I do not understand your reply.
I tried updating my powershell.exe.config with the connection string and membership stubs, as well as the full definitions added to the Dot.Net 4 machine.config file.
The user never gets added to the asp membership database using the new_spuser command in the same way it is listed by the OP. I have the same issue.
Are you asserting that if the Membership and Role provider config sections defining the FBA providers are properly added to the PowerShell config file that the command New-SPUser should add the user to the asp membership database in addition to defining the
user in SharePoint?
My code is attached. It can always be improved (better error handling, etc). You add the user info to the Users.CSV file. Edit the welcome.html template for your specific situation. Edit the createUsersAndNotify.ps1 script to meet your needs. ________________________________________
Andy McKenna | IT Consultant