Wednesday 11 February 2009

MOSS Developer handy dandy tips

The most common tips which a MOSS Developer may need :
1)Access STSADM from any directory while in command prompt.
  • Start -> All Programs -> Control Panel -> Advanced-->System
  • Click the Environment Variables -->variable Path -->Edit button.
  • ;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
  • Click OK. Dont forget ; before the variable path.
  • ******************************************************************************
    2) Recyle the Application Pool with command prompt.
  • Open the command prompt and then type in following line.
  • %windir%\system32\cscript.exe c:\windows\system32\iisapp.vbs /a "[Name of your App Pool]" /r.
  • In placeholder of Name --write your application pool which you wish to recycle.
  • There is also a small custom tool which would do this.http://www.harbar.net/apm/apm2.zip.
    ******************************************************************************
    3) Grab the Public Key Token while in Visual Studio Environment.
  • In Visual Studio 2005, click Tools -> External Tools...
  • Click Add and enter the following into the different fields as displayed in the following
  • Title: Grab Public Key value
    Command: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe
    Arguments: -Tp "$(TargetPath)"
    Check Output window option.
    Now when we have a signed project, and after building that project, just click on the Tools-->Grab Public Key value button, then we can see that value in the output window.
    ******************************************************************************
    4)Display all the Search Results before applying our custom XSLT/Styling
    a) Open the Search Results Page in Edit Mode.
    b) Click on "Modify Shared WebPart" link on "Search Core Results" web part.
    c) Click on XSL Editor button and in the Opened Editor window paste the following code.
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform > <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/">
    <xmp>
    <xsl:copy-of select="*"/>
    </xmp>
    </xsl:template>
    </xsl:stylesheet>

    d) Click OK and then refresh the page with search key word again then we can see the full results without any styling or customizations.
    ******************************************************************************
    5)Search for specific command in STSADM list at command prompt
  • We all often have seen when we type STSADM at its command prompt would show the huge list of its commands including the custom commands if we have any. It would be tiresome if we wanna run through the entire list to choose only one command which we forget that complete semantic.
  • For example if we want to create a site using STSADM then we can type in
    stsadm -help createsite. This shows the command with parameters.
    But if we want to rename the site then it would be tough for us trying to remember the correct operation Name.
  • But there is a way in which we can find all the relevant commands with keyword "site".
    Simply type in STSADM FIND "SITE" (with quotes, STSADM and Find are seperated using pipe symbol ) at the command prompt. It lists out all the commands which has word "site" in them.
  • Then pick your required command from them.

  • Check this link for all STSADM Commands and their purpose.


  • ******************************************************************************
    6) Export the (My)sites list to end user with less effort.
  • Recently I had a request from one of my client where they want to see all the MYSites of their corpnet users and their storage limits/details in XML format.
  • As usual STSADM came to my rescue with its wonderful command "enumsites".
    Just type in STSADM -o enumsites -url http://moss:xxxxx >>c:\MySitesList.xml
    And you are done. When the Operation is completed, then simply open C:\MySitesList.xml file for the details.

    ******************************************************************************


    7)Display Time at your Command prompt

    While executing the one of the STSADM commands, I found it took long time, but how much. We cant always look at the system time or your watch before executing command. I felt there should be some way in command window itself to show the command execution time.
  • Then after a small research, I found we can get the command executed time. Steps are following..
  • Open command prompt. Type in PROMPT $T $_ $P . And click enter.
  • Then the command prompt shows time before each command. Now we can find the total time of execution.

  • ******************************************************************************


    8) To Open Central Admin from command prompt

  • Make sure that "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\" is entered into environment variables as I mentioned earlier.
  • Then open command prompt type in psconfigui.exe -cmd showcentraladmin.
  • It opens the Central Admin quickly.

  • ******************************************************************************


    9) To perform mass publishing for documents/Images

  • Once the files are uploaded and every file is checked out, then go to that Library settings
  • Click on Versioning settings
  • Click on 'NO' for content Approval and click OK

  • Select Site Actions--Manage Content and Structure

  • And select the library and the items of the library would be displayed on the right pane. Select all of them and right click to find option "Publish".

  • It will do the trick. Once you are done then turn back Content Approval on

  • Even though this not a best practice, some times it help us

  • ******************************************************************************


    10) Saving output of STSADM command
    To save the output of STSADM Command into a text file use the following :
    eg:stsadm -o addsolution -filename MySoln.wsp >>output.txt 2>&1
    (Dont remove 2>&1--these are standard dos error handlers.)
    If we are using -immediate or -time or -local (Asynchronous commands) with STSADM command, then next STSADM command would fail. Like:
    stsadm -o retractsolution -name Mysolution.wsp -immediate
    stsadm -o deletesolution -name Mysolution.wsp
    The second command should execute after the first command has executed completely. But here it would fail.In order to avoid that we have two solutions
    Solution One:

  • echo some text pause

  • Solution Two:
  • Execadmsvcjobs command.But this should be used very carefully because it would execute all the administrative jobs immediately

  • ******************************************************************************



    11) Opening the Multiple Upload Window

    Sometimes, I have seen in the client environment, "MultipleUpload" link is not shown in document libraries,which we will discuss later, but as a simple trick to enable that, try to do following

    1. Open the document Library for which they cannot see "MultipleUpload"
    2. Click on "UploadDocument" and the window opens with URL /_layouts/Upload.aspx?=[ListID and some blah blah]
    3. Now add the "&MultipleUpload=1" at the end of the URL and press enter.

    It would open the MultipleUpload screen, still if you are unable to see "MultipleUpload", then refer the "Content Editor Web Part tricks" in Interesting Links.

    ******************************************************************************





    Happy SPD'ing

    1 comment:

    Monica Chopra said...

    Wonderful Work Murali.. You are a gem!