来源:http://sharepointsolutions.com/SharePoint-Add-ons/Products/Pages/Asset.aspx?AI=22
PowerShell Commands for SharePoint 2007
SharePoint Solutions' PowerShell Commands for SharePoint 2007
Copyright 2007,2008,2009 SharePoint Solutions. All rights reserved.
The SharePoint Solutions' PowerShell Commands for SharePoint 2007 provide admin utilities for SharePoint.
* DISCLAIMER: These utilities are Beta quality and should be evaluated in a test environment
Please follow the steps below. The entire process from installing PowerShell to getting a SharePoint 2007 FBA site setup should take less than 10 minutes.
*** Installation
1. Download the PowerShell 1.0 RC2 setup package from Microsoft at http://support.microsoft.com/kb/925228
2. Run the downloaded PowerShell installer
3. Run the SharePoint Solutions' PowerShell commands installer SPSolutionsPSCommands.msi
4. Open a new PowerShell command prompt
5. Allow scripts to run by issuing the command
Set-ExecutionPolicy Unrestricted
6. Register the SPSolutions snapin by issuing the command
add-pssnapin SPSolutionsSharePointCommands
*** Optional Installation
A few of the commands use PowerShell Community Extensions to send e-mail etc.
1. Download http://www.codeplex.com/PowerShellCX
2. Run the downloaded PowerShell Community Extensions installer
*** Using the menu-driven FBA Setup wizard
1. Run the FBA Setup wizard by issuing the command:
& "$env:spcshome\scripts\add-sqlfbawss.ps1"
2. To run the complete FBAWizard from start to finish, press w from the main menu
3. Each of the individual steps may also be run independently by selecting the appropriate letter
*** What the FBA Setup wizard does
1. Creates a ASP.NET SQL Server membership database (aspnetdb)
2. Adds an initial user to the SQL Server auth store
3. Creates a new SharePoint Web Application
4. Configures SharePoint web application with SQL membership provider and role manager
5. Adds a site collection to the web application configured with FBA authentication
Just press '?' at the main menu to get descriptions for each step
When all steps are completed, you should be able to login to your site collection as an FBA user.
Contact: http://software.sharepointsolutions.com/Pages/ContactUs.aspx
Support: http://software.sharepointsolutions.com/support
*** Bulk importing users to FBA
SharePoint Solutions' PowerShell commands includes utilities to bulk import users into FBA. The Copy-CsvToAspnetdb.ps1 script wraps the user import functions into an easy to use command.
Example: Importing users from Active Directory to FBA (note: The csvde utility comes with Windows Server, and exports AD users to an CSV:
1. csvde -f adusers.csv -r "(&(objectClass=User))" -l "sAMAccountName,sn,userPrincipleName,givenName,userPrincipalName"
2. C:\Program Files\SharePoint Solutions\SPSolutions PowerShell Commands\Scripts\copy-csvtoaspnetdb -csv .\adusers.csv -dbserver DEVHOST -dbname aspnetdb06 > log.txt 2>&1