Friday, October 2, 2009

Some helpful STSADM command

Some helpful STSADM command

----Starting Service MSSQLServer...
NET START "SQL Server (MSSQLServer)"

----ECHO Resetting IIS...
"C:\WINDOWS\system32\iisreset.exe"

----Creating Roles and Membership database...
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql" -S <SQL Server Name> -E -d "<DB Name>" -A all

----Copying **** config file
CD C:\Vinod\folder1
COPY /Y ****.xml "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\CONFIG"


----Installing and activating
STSADM -o activateFeature -filename *\feature.xml -url <Web app URL with Port> -force
----Deploy *.wsp solution package
--First adding solution package to farm...
STSADM -o addsolution -filename C:\folder1\*.wsp

--Deploying solution package to http://<MACHINENAME>:<CENTRALPORT> site... STSADM -o deploysolution -name *.wsp -url http://<MACHINENAME>:<CENTRALPORT> - allowgacdeployment -immediate -force

--STOP timers if any
STSADM -o execadmsvcjobs

--Error adding WSP Package; attempting upgrade instead
STSADM -o upgradesolution -filename C:\folder1\*.wsp -immediate -allowgacdeployment -allowcaspolicies

--STOP timers if any
stsadm -o execadmsvcjobs

----Adding Template
stsadm -o addtemplate -filename C:\folder1\TEMPLATE1.stp -Title "<TEMPLATENAME>"

----Create SSP
STSADM -o createssp -title "<SSP Title>" -url <SSP URL With PORT> -mysiteurl <MySite URL With PORT> -ssplogin <Domain Name>\<User ID> -ssppassword <Password> -indexserver <SQL Server name> -indexlocation "C:\Program Files\Microsoft Office Servers\12.0\Data\Office Server\SSPIndexes" -sspdatabasename <SSP DB Name> -searchdatabasename <SSP DB Name>

----Starting Office SharePoint Server Search...
STSADM -o osearch -action start -f -role IndexQuery -farmcontactemail <User Email ID> -farmserviceaccount <Domain Name>\<User ID> -farmservicepassword <Password> -defaultindexlocation "C:\Program Files\Microsoft Office Servers\12.0\Data\Office Server\OSSIndex"

----Extending "site" to internet zone
STSADM -o extendvsinwebfarm -url <New site with Port> -vsname "<Existing site>"

----Configuring Forms Authentication for webapp...
STSADM -o authentication -url <Web app URL with Port> -type forms -membershipprovider FBA_AspNetSqlMembershipProvider -rolemanager FBA_AspNetSqlRoleProvider

Create custom STSADM command

How to create custom STSADM command?
1. Create one class that inherited from ISPStsadmCommand class, And implements below method spcified in the Interface

public string GetHelpMessage(string command)
{
//Your help message.
}

public int Run(string command, StringDictionary keyValues, out string output)
{
//Your custom code using SP object model.
//Set out parameter as out on command prompt.
}

2. Above created dll need to have strong name key.
3. Register the above dll in GAC.
4. Make custom stsadmcommands..xml and put in @ C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\CONFIG.

This file contents the below command.

<Commands>
<command
name="createlist"
class="<ClassName>, <NameSpace>, Version=<No>, Culture=neutral, PublicKeyToken=<Key>"/>
</Commands>

5. Try to run command from command prompt.