Welcome to MSDN Blogs Sign in | Join | Help

Eric Kraus' SharePoint/.NET Blog

What the field says about MOSS.

News

  • Subscribe to this blog


    Eric Kraus on Live Messenger




      Disclaimer
      These postings are provided "AS IS" with no warranties and confer no rights. In addition, these postings are my own and do not represent the views of Microsoft.
    SharePoint 2010 Provisioning A New Farm with PowerShell

    This post will take you down the process of configuring your SharePoint farm while introducing the new administrative functionality shipping in the PowerShell provider.

    During the SharePoint Installation, make sure you choose “Server Farm” and then “Complete” install.  This will allow you to create a SharePoint farm rather than a standalone server.

    After the install completes, the setup program will ask you if you want to run the SharePoint Technologies Configuration Wizard (default is checked).  Uncheck the box to NOT run the wizard.

    Under the Start Menu, browse to Microsoft SharePoint 2010 Products.  Right-click on SharePoint 2010 Management Shell and choose Run as administrator

    0_StartPowerShell

    Notice:
    Since we have not created a farm yet, the shell will load with an error that the local farm is not accessible.  This is expected.

    Next, run the following command to create a new configuration database and central admin content database.  The main reason we are using this method, versus the GUI is because we can specify the central admin content database name.  (In the GUI, you cannot specify the name and it is created with a GUID)  <—DBA’s hate this

    New-SPConfigurationDatabase –DatabaseName “SharePoint2010_Config” –DatabaseServer “<db server>” –AdministrationContentDatabaseName “SharePoint2010_Admin_Content” –Passphrase (ConvertTo-SecureString “pass@word1” –AsPlaintext –Force) –FarmCredentials (Get-Credential)


    Notice: rather than hard coding the credential for the farm account, I am having PowerShell prompt me for it.  You can also do this with the passphrase by accessing the “Password” property of the of the credential object:  (Get-Credential).Password 


    1_NewConfigDB

    After the process runs, you can test that the server has not been added to a farm, by reloading the PowerShell window.  Close and repeat the “Run as administrator” step above.  It should load with no warning message.

    5_ReloadShowsFarmConnected

    Next, we need to provision the central admin web application on our desired port.  This will also link up the web application with the admin content database we created in the previous step.

    New-SPCentralAdministration -Port 1234 -WindowsAuthProvider "NTLM"

    After that command completes, we now need to install the features on the server. 

    Install-SPFeature –AllExistingFeatures

    21_InstallFeatures

    Lastly, we need to install and provision the services onto the farm.

    Install-SPService  -Provision

    DONE!  Now, you can open up Internet Explorer to the central admin site/port you specified and you’re on your way!
    PowerShell 2.0 Released!

    Windows Management Framework, which includes Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0, has been officially released today.  This down-level release is now supported for Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2 operating systems.

    You can find the release here:  http://go.microsoft.com/fwlink/?LinkID=151321

    Free PowerShell eBook

    For those wishing to get started on PowerShell, here is an excellent free eBook by Dr. Tobias Weltner, PowerShell MVP.

    http://powershell.com/Mastering-PowerShell.pdf

    Extending .NET Objects in PowerShell

    One of the great features in PowerShell 2.0 is the ability to extend .NET object types to add additional custom properties and methods.  For instance, the type System.String does not have a property called IsANumber that returns whether or not the string is a number.  Typically, you would have to do a TryParse.  By extending the System.String object, we can add such property.

    Here’s how it works:

    We will create a custom XML file that will define the .NET object that we would like to extend and how we want to extend it.  Then, we will load that XML into our PowerShell session and the new methods/properties will be available to us. 

    Types.ps1xml file, located at $pshome ships with PowerShell 2.0  It is a good place to look at example extensions.  Because this file is digitally signed, we cannot modify it directly, this is why we will create a custom XML file.

    Let’s get started.

    Open PowerShell by right clicking and choosing “Run as Administrator

    RunAsAdmin

    This next step (which is actually three commands) will create a new XML file “MyCustomTypes.ps1xml” at the $pshome location,  (typically:  C:\Windows\System32\WindowsPowerShell\v1.0) and open it in Notepad.

    $mycustfile = “$pshome\MyCustomTypes.ps1xml”; New-Item –ItemType File –Path $mycustfile; notepad $mycustfile

    Note:
    we are using PowerShell 2.0 but the install location for that is called “1.0”

    Next, add the following XML to the notepad window that opened:

    <?xml version="1.0" encoding="utf-8" ?>
    <Types>
      <Type>
        <Name>System.String</Name>
          <Members>
            <ScriptProperty>
              <Name>IsANumber</Name>
              <GetScriptBlock>
                    $out = $null; [System.Double]::TryParse($this, [ref] $out)
              </GetScriptBlock>
          </ScriptProperty>
        </Members>
      </Type>
    </Types>

    The $this property is the current object of the type you are extending.  In our example it will always be a string, since we are extending the System.String object.

    Save and close Notepad

    Back in PowerShell type the following command to load the custom types xml file and give it higher precedence than any other loaded file:


    Update-TypeData -PrependPath $mycustfile


    Now, to test that the new property has been added, we can create a new string variable and check the IsANumber property.

    RunTest 

    Below are a few of the different types of extensibility that you can perform:

    <AliasProperty> – defines a new name for an existing property
    <CodeMethod> – references a static method of a .NET class as a method for the object
    <CodeProperty> – references a static method of a .NET class as a property for the object
    <NoteProperty> – defines a property with a static value
    <ScriptMethod> – defines a method whose output is the value of a script
    <ScriptProperty> – defines a property whose output is the value of a script

    For more information:  
    get-help about_types.ps1xml  and  get-help update-typedata

    SharePoint 2010: A Developer’s Top 15 List

    Developers of SharePoint should be giddy with excitement in all of the tools and features coming out of Visual Studio 2010 and SharePoint Designer 2010.  Here are the biggest take-a-ways from Paul Andrew’s talk on the 2010 developer platform:

    1. “Save site as template” now exports as a WSP which can be imported into Visual Studio 2010 as a new project

    2. BDC is now Business Connectivity Services which supports full Create, Read, Update, Delete calls to sources, plus Office 2010 integration using new SharePoint Designer 2010 tools 

    3.  LINQ to SharePoint to replace complex CAML queries in code.  Strongly typed, intelli-sense, joins and projections
               
    4.  Developer Dashboard displays call stack, load time, and other valuable data to debug and review code

    5.  Relationships between lists, supporting cascade deletes (transactions are actually handled on SQL Server)

    6.  Large List?  No problem! Just be certain of data in views.  Use throttling and indexes for performance.  10’s to 100’s of thousands of documents = no problem.

    7.  Column Validation – lets us add validation logic when defining columns

    8.  Client Object Model – simple API to Add, Retrieve, Update and Manage data.  Commands are batched for performance:

    ClientContext cnt = new ClientContext (“http://siteurl”);
    Web site = context.Web;
    context.Load(site);
    context.ExecuteQuery();
    site.Title = “Something New”;
    site.Update();
    context.ExecuteQuery();

    9.  Rest APIs – uses ADO.NET Data Services.  Out of the box services in SharePoint.  Retrieve data off of site in 3 lines of code.

    10.  Better Events and Workflow.  Event Receivers and Workflows now possible at the site scope level (workflow does not bind to a list).  Event receivers can run asynchronously

    11.  Easily build dialog forms using AJAX. 

    12.  Silverlight web part out of the box. - code doesn’t need to run on server!!!

    13.  Sandboxed Solutions – can monitor counters on server (CPU, RAM, etc.) to automatically shutdown bad code.  Uses a proxy worker process so not direct access to Microsoft.SharePoint.dll

    14.  WSP is the unified developer platform (for both Site Collections and local machine)

    15.  Integration with Team Foundation Server (TFS):  work item tracking, source control, team build, manage test cases, automated testing, and load testing!

    PowerShell Cmdlets in SharePoint 2010

    You may have already heard that SharePoint 2010 will ship with a PowerShell provider that contains over 500 cmdlets for you to administer SharePoint. The killer though, is that these commandlets can be executed remotely with PowerShell 2.0 WinRM.  Awesome!  Don’t worry about STSADM, it will still be around to support existing administration scripts and utilities. 

    You can load the PowerShell provider by typing:

    add-pssnapin Microsoft.SharePoint.PowerShell

    Much of what Christian (iLoveSharePoint) and I have worked on in SPoshMod for SharePoint 2007 supports the same pattern as the 2010 provider.  Verb-Noun, with SP prefix.   Get-SPSite, Get-SPWeb, etc.

    What you may not know is that developers can add custom providers and deploy them to SharePoint.  You can do this by using the Microsoft.SharePoint.PowerShell  namespace.  To distinguish a normal PowerShell cmdlet from a SharePoint cmdlet, an new abstract class has been added to the namespace called: SPCmdlet  (other cmdlets inherit directly from PSCmdlet).

    More to come on this topic…

    Live Blogging from SharePoint Conference 2009

     

    I’ll be at SharePoint Conference 2009 and will be participating with EndUserSharePoint.com in their LiveBlogging sessions. 

    Live blogging/twittering at SharePoint Conference 2009:


    SharePoint Conference 2009

    I will be attending the SharePoint Conference in Las Vegas next week and wanted to share my schedule with those that might be interested in checking back for content.  I will be blogging on content throughout the event. There may be multiple sessions listed under a given timeslot as I will be narrowing down content as I attend other sessions. 

    I will be cross posting some content on my blog with EndUserSharePoint.com  more info can be found on my next blog post:

    --> Live Blogging from SharePoint Conference 2009 

    or on Twitter:   http://twitter.com/erickraus

    Monday, October 19th, 2009
    9:00 AM  - Keynote: Unveiling Microsoft SharePoint 2010
    Speaker: Steve Ballmer
    10:30 AM  -  Keynote: Microsoft SharePoint 2010 Drilldown
    Speaker: Jeff Teper
    1:15 PM  -  Overview of the SharePoint 2010 Developer Platform
    2:45 PM  - 
    SharePoint 2010 Administration: Part 1
    Visual Studio 2010 SharePoint Development Tools Overview
    4:30 PM  - 
    SharePoint 2010 Administration: Part 2
    Overview of Social Computing in SharePoint 2010
    Developing with SharePoint 2010 Sandboxed Solutions

    Tuesday, October 20th, 2009
    9:00 AM  - 
    Building Rich Internet Applications with Silverlight 3 and...
    Advanced Web Part Development in Visual Studio 2010
    Overview of Office 2010 for the IT Pro
    10:30 AM  - 
    Building A Great Extranet: Proven Principles & Best Practices
    Scaling SharePoint 2010 topologies for your organization
    1:15 PM  - 
    SharePoint isn’t just for Servers anymore
    Developing SharePoint 2010 Applications with the Client Object Model
    Authentication and Authorization in SharePoint 2010
    2:45 PM  -  Deep Dive into SharePoint 2010 My Sites and Social Networking...

    Wednesday, October 21th, 2009
    9:00 AM  -  Developing an Automated Site Management Lifecycle with SharePoint 2010
    10:30 AM  -  Business Connectivity Services Runtime and Object Model Deep Dive
    1:15 PM  -  Developing with REST and LINQ in SharePoint 2010
    2:45 PM  - 
    Externalizing BLOB Storage in SharePoint 2010
    Developing Social Applications with SharePoint 2010
    4:30 PM  -  Advanced Development for Silverlight 3 in SharePoint 2010

    Thursday, October 22th, 2009
    9:00 AM  -  Unveiling New Management Tools for Administering SharePoint 2010
    10:30 AM  -  Application Lifecycle Management for Developers in SharePoint 2010
    12:00 PM  -  Upgrading SharePoint 2007 code to SharePoint 2010

    Custom Site Definition Alternative

    This came up for a recent customer, so thought I would share my solution as many people are not aware of this customization possibility.  The solution ultimately solved the problem that feature staplers activate features BEFORE any lists are provisioned on a site.  So, the only eloquent way to modify a list or list item is to create a new list template in a new site definition.  Here is an alternative solution to consider instead of supporting another site definition in your environment.

    When SharePoint shows you the list of site definitions available to create a new site, it compiles this list from the list of files in: 12 Hive\TEMPLATE\1033\XML\    SharePoint will collectively pull all of the contents in the files named: webtemp*.xml and display a list of available site definitions.  By creating your own webtempcustom.xml you can effectively add site definitions to the list of choices at the ‘create’ screen. (nothing new here)

    However, you don’t necessarily have to create a site definition along with your webtemp*.xml file.  Instead, you can call custom code to build your site to your needs and return that site to the provisioning process.  This can be accomplished by leveraging the SPWebProvisioningProvider class when a new site is created.  This class, which is inherited from, is specified in your webtempcustom.xml file.

    Here is an example of a webtempcustom.xml file with the provisioning class specified:

    webtempcustom
    And the provisioning class:

    provisioningprovider

    Now, just deploy your xml file to the 12\TEMPLATE\1033\XML folder and your compiled DLL to the GAC.  When the site is created, it will still be created with the STS#0 (or the template you apply in your code.  Essentially, eliminating the dependency on any other site definitions.

    Another thought, you could even add the ProvisionAssembly and ProvisionClass to an existing template entry such as STS to override the provisioning process for an existing site definition.

    Twin Cities SharePoint Camp v3

    Here’s a great (FREE) opportunity to attend a day-long workshop completely dedicated to SharePoint.  Come learn from developers, IT Pros, consultants, and local companies who have implemented SharePoint and have a story to share.

    I will be presenting again this year on one of my favorite topics, PowerShell.  Here is an abstract of the session:

    PowerShell Administration and Development in SharePoint

    PowerShell is a hot topic for SharePoint 2007 and will be even more for 2010.  Discover the power of PowerShell 2.0 and PowerGUI as they are used to perform advanced administrative & development tasks in SharePoint.  This session will start with a brief introduction to PowerShell scripting and continue with a look into helpful SharePoint scripts including: filtering event and ULS logs, managing sites and users, streamlining feature development, managing web parts, working with the object model, and much more!  Both administrators and developers will benefit from this powerful discussion.


    More information, and steps to register, can be found here:  http://twincitiessharepointcamp.com/

    Hope to see you there!

    Microsoft Certification Discounts


    exams

    For those looking to ramp up on a new technology or finally add that certifications under your belt, here is a great offer from Microsoft.  You can save up to 20% on MCTS exams through the end of the year.

    This offer is available worldwide while supplies last, and you have to register, schedule and purchase your discounted exam by December 31, 2009.   

    For more information:  http://www.microsoft.com/learning/careeroffers

    Searching SharePoint with Windows 7 Search Connectors

    Windows 7 allows you to create custom search connectors to various OpenSearch standard search engines, e.g. Bing and you guessed it:  SharePoint!  Creating a search connector is super easy!

    1.  Open Notepad and copy in the XML below

    2.  Replace the areas in red with your SharePoint Search Center information.  Be sure to only replace just the part of the URL that gets to your Search Center:  e.g.  http://sharepoint.company.com/SearchCenter   You can also change the scope:  e.g.  &amp;s=Intranet  or  &amp;s=All%20Sites  or even  &amp;s=People

    3.  Save the file to your Desktop as:    SharePointSite.osdx

    4.  Double click the file to install the Search Connector.  (it will install to your “Searches” directory  e.g.   c:\Users\<username>\Searches

    Optional:  you can add a shortcut the favorites area on any Windows Explorer window by dragging the installed Search Connector there.


    ------------------------------------------------------------------------------------

    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:ms-ose="http://schemas.microsoft.com/opensearchext/2009/">
    <ShortName>SharePoint Search</ShortName>
    <Description>Search the SharePoint site.</Description>
    <Url type="application/rss+xml" template="http://sharepoint.company.com/searchcenter/_layouts/srchrss.aspx?k={searchTerms}&amp;s=All%20Sites"/>
    <Url type="text/html" template="http://sharepoint.company.com/searchcenter/Pages/Results.aspx?k={searchTerms}&amp;s=All%20Sites"/>
    <ms-ose:ResultsProcessing format="application/rss+xml">
    <ms-ose:LinkIsFilePath>-1</ms-ose:LinkIsFilePath>
    </ms-ose:ResultsProcessing>
    </OpenSearchDescription>

    Packing up My Documents: A PowerShell Story

    I am frequently asked by colleagues and customers for a dump of all of my SharePoint content (presentations, white papers, etc.)  While I continue to add files like these to my hard drive in various different locations, it has started to take me a while to aggregate them all forward.  It dawned on me that this need not be a half an hour exercise of locating documents.

    Bing!  PowerShell

    Thanks to another colleagues blog:  http://blogs.msdn.com/daiken/archive/2007/02/12/compress-files-with-windows-powershell-then-package-a-windows-vista-sidebar-gadget.aspx

    I created a few functions and added them to my PowerShell module that loads with my profile.  Now it’s as simple as:


    Get-ChildItem -path c: -filter *sharepoint* -recurse | create-zip "c:\sharepoint.zip"

    #Special Thanks to: 
    # http://blogs.msdn.com/daiken/archive/2007/02/12/compress-files-with-windows-powershell-then-package-a-windows-vista-sidebar-gadget.aspx

    # Create a new zip file from pipeline
    function Create-Zip()
    {
        param
        (
            [string]$zipFile
        );
       
        New-Zip -zipfileName $zipFile
        $zip = Get-Zip -zipfileName $zipFile
       
        #loop through files in pipeline
        foreach($file in $input)
        {
            #add file to zip and sleep 1/2 second
            $zip.CopyHere($file.FullName)
            Start-sleep -milliseconds 500
        }

    }

    #create a new zip file
    function New-Zip
    {
        param([string]$zipfilename)
        set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
        (dir $zipfilename).IsReadOnly = $false
    }

    #get the zip file
    function Get-Zip
    {
        param([string]$zipfilename)
        if(test-path($zipfilename))
        {
            $shellApplication = new-object -com shell.application
            $zipFullFilename = (get-childitem $zipfilename).FullName
            $shellApplication.NameSpace($zipFullFilename)
        }
    }

    Twitter Basics

    Twitter for those who just want to consume information…

    By now most of the world has at least heard of Twitter. For those who aren’t already using it, I imagine the vast majority have taken a stance of  “Why would anyone care when I go to the bathroom?”  Or, “Not another web site I need to sign up for…” 

    Well, as an avid Twitter user, I couldn’t agree more.  However, there is a RIDUCULOUS amount of quality information out on Twitter to consume, information that doesn’t require you to create an account to retrieve.  Albeit, creating one will bring you added value…  The real tricks are finding the right people and filtering out all of the garbage. 

    Here are some tips that have helped me find great value in this tool:

    Finding Information

    -If you are looking for people to follow, check out http://twibes.com It’s a collection of “opt-in” groups of people that usually Twitter about a common topic. The site gives you an aggregated view of what these people are saying. It’s an easy way to find people that are consistently providing good content on a subject.  Once you find a few people, you can go to a person’s Twitter page (http://twitter.com/<username>) and see who he/she is following.  No guarantee, but good chance they are following other quality people.

    Twibe
    “SharePoint” group on Twibes


    -If you are just looking for some content, check out http://topsy.com.  It’s a search engine crawling only Twitter messages with links, based on popularity. 

    Topsy
    Search for “sharepoint” on Topsy


    -While I don’t like the Twitter web site itself, I don’t mind Twitter search.  http://search.twitter.com  The biggest benefit here is the available RSS feed.

    twitterSearch
    Twitter Search

    How to consume?

    While visiting these sites gives you an easy way to access this information without even creating an account, it may not be as convenient as other methods.  After you find people to follow or search criteria from these sites, you will notice that most provide an RSS feed for your query.  Add that RSS feed to Internet Explorer, Outlook 2007, or other RSS reader. 

    -Another great site is http://www.peoplebrowsr.com/  It’s basically TweetDeck (see below) as a website.  While still a bit buggy in beta, it’s a great way to configure search queries like in TweetDeck without creating an account or downloading a client application.

    peopleBrowsr
    PeopleBrowsr


    If you decide to contribute, some additional tips:

    -Sign up for an account on Twitter.com site and then close your browser. The Twitter web application is horrible and you’ll never find value using the website.

    -Download TweetDeck  After you set it up, add a couple search columns based on what information you are looking for.

    TweetDeck
    My TweetDeck

    -Network!  “RT” (re-tweet) messages that you find useful. It exposes you to the author. If the author thinks you provide good content, he/she will follow you. The more people that follow you, the more that will see the messages you contribute. This is useful when you are looking to post a question.

    I look at Twitter as a personal AP wire. There’s a lot of information traveling by, but with a few custom searches/filters, I can grab some really good info. I spend a few minutes every night reading what the world is saying about SharePoint, PowerShell, Microsoft, and Kate Moss. Just kidding about Kate Moss…but for a while I did get some garbage float in on my “MOSS or WSS” search.

    Additionally, Twitter has become an informal support forum for questions like, “Has anyone seen this error before….” I usually get a response or two within 5 minutes.

    Even if you never contribute, Twitter is an excellent source of “what’s going on in the world regarding ____ “ I encourage you to check it out.  Just don’t try to read everything…

    PowerShell Shortcuts

    I’m all about shortcuts when it comes to development and there’s no exception for PowerShell.

    Browsing around this morning, I found two useful shortcuts that I didn’t know existed.

    F7  “History”-  Pressing the F7 key will show a dialog window in PowerShell with a list of commands from your history.  You can also access this list by using the cmdlet  “Get-History”  but I find the dialog WAY more easy than the cmdlet or using the Up arrow key.

    F8  “Filtered Commands” -  Pressing the F8 key is much like using the Up arrow key to scroll backwards through your list of commands; however, it allows you to filter the list of commands.  Here’s an example of a list of commands:

    1.  cls
    2.  Write-Host “Starting my example”
    3.  cls
    4.  Write-Output “This is fun”
    5.  cls
    6.  Write-Warning –message “Uh oh, too much fun”
    7.  cls
    8.  Write-Host “Ending my example”

    The way to efficiently use F8, is for command line 6, type only: “write” and then press F8 several times.  It will cycle through all of your previous commands, but only those that started with “write”  (lines 2, 4, and 6). 

    Cool: - you will also notice that the cursor is positioned at the end of your filter, so you can easily move it ahead or behind and do a Ctrl + End  to delete the rest of the command line to continue writing.

    More Posts Next page »
    Page view tracker