<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>John W Powell : Windows SharePoint Services</title><link>http://blogs.msdn.com/johnwpowell/archive/tags/Windows+SharePoint+Services/default.aspx</link><description>Tags: Windows SharePoint Services</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Subscribe to SharePoint Web Parts using Internet Explorer 8 Web Slices</title><link>http://blogs.msdn.com/johnwpowell/archive/2009/02/01/subscribe-to-sharepoint-web-parts-using-internet-explorer-8-web-slices.aspx</link><pubDate>Mon, 02 Feb 2009 00:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9388724</guid><dc:creator>johnwpowell</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/johnwpowell/comments/9388724.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johnwpowell/commentrss.aspx?PostID=9388724</wfw:commentRss><description>&lt;P&gt;One of the new features of Internet Explorer 8 is &lt;EM&gt;Web Slices.&amp;nbsp; &lt;/EM&gt;This feature enables you to subscribe to a &lt;EM&gt;section&lt;/EM&gt; of a web page and notifies you when the content changes.&amp;nbsp; By design, SharePoint Web Parts are a natural fit for this feature, and in this article I’ll show you how to build a Web Part that does just that.&amp;nbsp; I’ll also show you how easy it is to develop a web part using the CTP release of Visual Studio 2008 Extensions for Windows SharePoint Services (VSSWse) 1.3.&lt;/P&gt;
&lt;H3&gt;About Web Slices&lt;/H3&gt;
&lt;P&gt;Web Slices enable you to have a very narrow control over the content you subscribe to.&amp;nbsp; When you browse a page that has Web Slice sections, they “light up” when you hover over them:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_2.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb.png" width=344 height=68 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;In addition, the new Web Slice icon on the toolbar lights up, and the menu is populated with all the slices on the page:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_4.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_4.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_1.png" width=198 height=59 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_1.png"&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;When you subscribe to a slice, the web page section is added to the toolbar and is periodically refreshed.&amp;nbsp; The refresh interval is completely customizable and can also be refreshed manually:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_6.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_6.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_2.png" width=426 height=297 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_2.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;Defining a Web Slice Section&lt;/H3&gt;
&lt;P&gt;Web Slices are defined with HTML tags that have certain CSS classes.&amp;nbsp; You can read the &lt;A href="http://msdn.microsoft.com/en-us/library/cc304073%28VS.85%29.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc304073%28VS.85%29.aspx"&gt;full specification&lt;/A&gt;, but here’s all you need to know to build your first Web Slice:&lt;/P&gt;
&lt;P&gt;To define a Web Slice section, use the &lt;EM&gt;hslice&lt;/EM&gt; class name:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;div class="hslice" id="1"&amp;gt;…&amp;lt;/div&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To define the slice title, use the &lt;EM&gt;entry-title&lt;/EM&gt; class name:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;p class="entry-title"&amp;gt;Game System - $66.00&amp;lt;/p&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To define the slice content, use the &lt;EM&gt;entry-content&lt;/EM&gt; class name:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;div class="entry-content"&amp;gt;This auction closes in 4 hours.&amp;lt;/div&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The end result looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;&amp;lt;div class="hslice" id="1"&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;p class="entry-title"&amp;gt;Game System - $66.00&amp;lt;/p&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="entry-content"&amp;gt;This auction closes in 4 hours.&amp;lt;/div&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;/div&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;H3&gt;Build a SharePoint Web Part&lt;/H3&gt;
&lt;P&gt;For this example, I’m using VSSWSE 1.3 which you can read about &lt;A href="http://blogs.msdn.com/sharepoint/archive/2009/01/12/announcing-community-technology-preview-of-visual-studio-2008-extensions-for-sharepoint-v1-3.aspx" target=_blank mce_href="http://blogs.msdn.com/sharepoint/archive/2009/01/12/announcing-community-technology-preview-of-visual-studio-2008-extensions-for-sharepoint-v1-3.aspx"&gt;here&lt;/A&gt;.&amp;nbsp; I would recommend it not only because it’s easy to use, but also because it is sure to become the de-facto standard.&amp;nbsp; To get started, create a new Web Part project:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_8.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_8.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_3.png" width=616 height=442 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_3.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Choose if you want to deploy to the GAC or bin directory.&amp;nbsp; We’ll use GAC for this example:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_10.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_10.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_4.png" width=362 height=215 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_4.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A solution is created with a default web part named WebPart1.&amp;nbsp; Rather than renaming it, delete the WebPart1 folder and add a new Web Part to the project with a more descriptive name:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_12.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_12.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_5.png" width=616 height=373 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_5.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Next, configure the url of your SharePoint site you want to use to test the Web Part.&amp;nbsp; On the Debug settings, set the start url:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_20.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_20.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_9.png" width=615 height=113 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_9.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;In the Web Part, override the CreateChildControls method:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_16.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_16.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_7.png" width=616 height=363 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_7.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code generates the needed HTML and is pretty self-explanatory.&amp;nbsp; I chose to hide the Web Slice entry-title as it would be redundant beneath the Web Part title.&amp;nbsp; To test the code, right-click the solution or project and select Deploy.&amp;nbsp; This will package the Web Part as a feature and deploy and activate it on the site:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_22.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_22.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_10.png" width=392 height=169 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_10.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, add the Web Part to a page in the site and test it.&lt;/P&gt;
&lt;H3&gt;How I Wished It Worked&lt;/H3&gt;
&lt;P&gt;Web Slices are powerful, but I don’t really want to develop a bunch of new Web Parts to use that feature.&amp;nbsp; I wish every Web Part were capable of wrapping its content in a Web Slice div tag.&amp;nbsp; I’m sure there is a way to inject this functionality (and there might even be a supported method), but I wish it were built in to the Web Part framework.&amp;nbsp; Every Web Part could then have a Web Slice category with relevant settings:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_18.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_18.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_8.png" width=237 height=219 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_8.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Wouldn’t that be powerful?&lt;/P&gt;
&lt;H3&gt;Summary&lt;/H3&gt;
&lt;P&gt;In this article, I demonstrated how to build a Web Part that users can subscribe to using Web Slices.&amp;nbsp; I also showed you how easy it is to build a Web Part using the CTP release of Visual Studio 2008 Extensions for Windows SharePoint Services version 1.3.&amp;nbsp; Happy slicing!&lt;/P&gt;
&lt;H3&gt;References and Additional Reading&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/windows/internet-explorer/download-ie.aspx" target=_blank&gt;Internet Explorer 8 Download&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc196992(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc196992(VS.85).aspx"&gt;Subscribing to Content with Web Slices&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc304073%28VS.85%29.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc304073%28VS.85%29.aspx"&gt;Web Slice Format Specification&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=4A7F2178-DB7E-4325-98B5-15FA725708E2&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=4A7F2178-DB7E-4325-98B5-15FA725708E2&amp;amp;displaylang=en"&gt;Web Slice Icon and Guidelines&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://www.microsoft.com/windows/internet-explorer/beta/videos.aspx?vindex=3" target=_blank mce_href="http://www.microsoft.com/windows/internet-explorer/beta/videos.aspx?vindex=3"&gt;Internet Explorer 8 Videos : Web Slices&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9388724" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/.Net/default.aspx">.Net</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/WSS/default.aspx">WSS</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/WSS3/default.aspx">WSS3</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/Windows+SharePoint+Services/default.aspx">Windows SharePoint Services</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/MOSS/default.aspx">MOSS</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/SharePoint+2007/default.aspx">SharePoint 2007</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/SharePoint/default.aspx">SharePoint</category></item><item><title>Build PowerShell CmdLets to call SharePoint Web Services using WCF</title><link>http://blogs.msdn.com/johnwpowell/archive/2008/11/02/build-powershell-cmdlets-to-call-sharepoint-web-services-using-wcf.aspx</link><pubDate>Mon, 03 Nov 2008 00:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9029678</guid><dc:creator>johnwpowell</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/johnwpowell/comments/9029678.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johnwpowell/commentrss.aspx?PostID=9029678</wfw:commentRss><description>&lt;P&gt;In this post I'll show you how to build a PowerShell cmdlet that consumes SharePoint web services using WCF.&amp;nbsp; What I like about this approach is that it provides the ability to use &lt;EM&gt;some&lt;/EM&gt; of the SharePoint API without having to be logged in to the SharePoint server.&amp;nbsp; Although you can accomplish the same thing using PowerShell scripts and functions, in this post we'll build a SharePoint cmdlet using C#.&amp;nbsp; &lt;/P&gt;
&lt;H3&gt;About the Approach&lt;/H3&gt;
&lt;P&gt;There are several advantages of combining PowerShell and SharePoint web services:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Consume the SharePoint API without logging on to a SharePoint server 
&lt;LI&gt;Provide a layer of abstraction and reusable task-oriented building blocks 
&lt;LI&gt;Reduce risk of performance issues caused by PowerShell scripts that don't dispose of unmanaged SharePoint resources&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;There are also some drawbacks to writing custom cmdlets that consume SharePoint web services:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SharePoint web services do not expose the full API; you may need to augment them with business-specific functionality 
&lt;LI&gt;Cmdlets require compilation and additional overhead over script file&lt;/LI&gt;&lt;/UL&gt;
&lt;H3&gt;Getting Started&lt;/H3&gt;
&lt;P&gt;In this walkthrough, I'm using Visual Studio 2008 on a SharePoint virtual machine.&amp;nbsp; Although you &lt;EM&gt;could&lt;/EM&gt; use a Visual Studio PowerShell project template, we'll are going to build everything by hand so there are no mysteries.&amp;nbsp; So let's get started by creating a new class library project:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_2.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_2.png"&gt;&lt;IMG height=163 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb.png" width=240 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a reference to PowerShell which is contained in System.Management.Automation assembly.&amp;nbsp; If you've installed the Windows SDK, you can find it in the following location: C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image3.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image3.png"&gt;&lt;IMG height=197 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image3_thumb.png" width=240 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image3_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Since we are creating a class that will both describe and install a custom snap in, we need to reference System.Configuration.Install&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image9.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image9.png"&gt;&lt;IMG height=197 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image9_thumb.png" width=240 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image9_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H3&gt;Create the Snap In and Cmdlet&lt;/H3&gt;
&lt;P&gt;Add a new class that inherits CustomPSSnapIn.&amp;nbsp; Add the RunInstaller attribute to the class and describe the snap in by overriding the Name, Vendor and Description properties.&amp;nbsp; Your code should end up looking like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image12.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image12.png"&gt;&lt;IMG height=783 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image12_thumb.png" width=515 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image12_thumb.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a new class that inherits from Cmdlet.&amp;nbsp; We'll build a cmdlet to get information about a SharePoint site, so name it "GetSPWebCmdlet."&amp;nbsp; Add the Cmdlet attribute to the class. You'll notice the cmdlet name, "Get-SPWeb" is a combination of the noun string &lt;EM&gt;SPWeb&lt;/EM&gt; and verb enumeration &lt;EM&gt;VerbsCommon.Get&lt;/EM&gt; specified by the Cmdlet attribute:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image18.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image18.png"&gt;&lt;IMG height=289 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image18_thumb.png" width=386 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image18_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Override the Cmdlets property in the snap in class and add the Get-SPWeb cmdlet to the Cmdlets collection:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image21.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image21.png"&gt;&lt;IMG height=231 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image21_thumb.png" width=805 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image21_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H3&gt;Configure Visual Studio to Install and Add the Snap In When the Project is Debugged&lt;/H3&gt;
&lt;P&gt;Before we add any code to the cmdlet, let's configure Visual Studio to automatically deploy the snap in to make debugging easier.&amp;nbsp; We'll use a post-build event to install the snap in, so in the spirit of learning PowerShell, we'll write the post-build script in PowerShell!&amp;nbsp; Add a new text file to your project named PostBuildEvent.ps1.&amp;nbsp; Add the following script to the file:&lt;/P&gt;
&lt;P&gt;trap &lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp; $errorTxt = $_.Exception.Message&lt;BR&gt;&amp;nbsp;&amp;nbsp; write-output "$errorTxt"&lt;BR&gt;&amp;nbsp;&amp;nbsp; break&lt;BR&gt;} 
&lt;P&gt;$targetDir = $args[0]&lt;BR&gt;$targetFileName = $args[1]&lt;BR&gt;$snapInName = $args[2] 
&lt;P&gt;write-output "Deploying..."&lt;BR&gt;join-path $targetDir $targetFileName&lt;BR&gt;write-output "Snap In Name: $snapInName" 
&lt;P&gt;set-location $targetDir&lt;BR&gt;set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil&lt;BR&gt;installutil $targetFileName 
&lt;P&gt;Notice the script file takes some arguments (targetDir, targetFileName and snapInName).&amp;nbsp; Using that information, it installs the SnapIn (and our SharePoint cmdlet).&amp;nbsp; Configure Visual Studio to pass the arguments to the post-build event:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image27.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image27.png"&gt;&lt;IMG height=235 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image27_thumb.png" width=422 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image27_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;After a SnapIn is installed, you have to add it to your environment before it can be used.&amp;nbsp; As you can see, even though our custom snap in has been installed, it is not listed when you call &lt;EM&gt;Get-PSSnapin&lt;/EM&gt;:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_20.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_20.png"&gt;&lt;IMG height=212 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_7.png" width=640 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_7.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;To add it, call &lt;EM&gt;Add-PSSnapin&lt;/EM&gt; passing in the name of the assembly:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_22.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_22.png"&gt;&lt;IMG height=158 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_9.png" width=640 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_9.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;We don't want to add the snap in after each code change, so we are going to automate it by adding a console file that will add the snap in into our environment when the project is debugged.&amp;nbsp; Add a new file named SharePointSamples.Console.psc1 to your project.&amp;nbsp; Put the following xml in the file:&lt;/P&gt;
&lt;P&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;BR&gt;&amp;lt;PSConsoleFile ConsoleSchemaVersion="1.0"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;PSVersion&amp;gt;1.0&amp;lt;/PSVersion&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;PSSnapIns&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;PSSnapIn Name="SharePointSamples.PowerShell" /&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/PSSnapIns&amp;gt;&lt;BR&gt;&amp;lt;/PSConsoleFile&amp;gt; 
&lt;P&gt;In the project configuration, Debug settings, configure Visual Studio to start PowerShell when you debug and in the command-line arguments section, use the -PSConsoleFile argument to specify the console file you created:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_16.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_16.png"&gt;&lt;IMG height=316 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_2.png" width=499 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H3&gt;Implement the Cmdlet&lt;/H3&gt;
&lt;P&gt;Now that deployment and debugging are taken care of, add the following code to the cmdlet:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_24.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_24.png"&gt;&lt;IMG height=568 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_10.png" width=711 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_10.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;The cmdlet takes the url of the site as an argument.&amp;nbsp; Arguments are implemented as class properties decorated with the &lt;EM&gt;Parameter&lt;/EM&gt; attribute.&amp;nbsp; The work is implemented in the &lt;EM&gt;ProcessRecord&lt;/EM&gt; method.&amp;nbsp; As you can see, I already did some re-factoring and created a service locator class that will give me an instance of the SharePoint &lt;EM&gt;Webs&lt;/EM&gt; service (using WCF).&amp;nbsp; The code then invokes the &lt;EM&gt;GetWeb&lt;/EM&gt; method and writes out the resulting xml.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Here is the code for the service locator.&amp;nbsp; As you can see it configures the SharePoint Webs proxy: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_28.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_28.png"&gt;&lt;IMG height=324 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_12.png" width=640 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_12.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Most of the key WCF configuration settings for integrated authentication are implemented in the BindingFactory class:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_30.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_30.png"&gt;&lt;IMG height=311 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_13.png" width=640 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_13.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;H3&gt;Test the Cmdlet&lt;/H3&gt;
&lt;P&gt;To test the cmdlet, run the project.&amp;nbsp; When the PowerShell command prompt opens, type &lt;EM&gt;Get-SPWeb&lt;/EM&gt;.&amp;nbsp; You will be prompted for the site url if you don't provide it:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_26.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_26.png"&gt;&lt;IMG height=217 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_11.png" width=505 border=0 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/d480dd7087aa_8548/image_thumb_11.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;Summary&lt;/H3&gt;
&lt;P&gt;In this walkthrough, you learned how to leverage PowerShell, WCF and the SharePoint web services to implement a custom cmdlet.&amp;nbsp; Using this approach, you can expand the administrative capabilities of SharePoint and build reusable, task-oriented building blocks to increase your productivity and capability.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://cid-7cedcb8ed3a44629.skydrive.live.com/self.aspx/Public/SharePointSamples.zip" target=_blank mce_href="http://cid-7cedcb8ed3a44629.skydrive.live.com/self.aspx/Public/SharePointSamples.zip"&gt;Get the code&lt;/A&gt; for this article.&lt;/P&gt;
&lt;H3&gt;Additional Reading&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.capdes.com/2007/03/visual_studio_post_build_event.html" target=_blank mce_href="http://www.capdes.com/2007/03/visual_studio_post_build_event.html"&gt;Visual Studio Build Events With PowerShell&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://www.wrox.com/WileyCDA/Section/id-320555.html" target=_blank mce_href="http://www.wrox.com/WileyCDA/Section/id-320555.html"&gt;Extending Windows Powershell with Snap-ins&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://sharepoint.microsoft.com/blogs/zach/Lists/Posts/Post.aspx?List=90bbfd11-c9a5-45cf-a77e-19559aae81ae&amp;amp;ID=7" target=_blank mce_href="http://sharepoint.microsoft.com/blogs/zach/Lists/Posts/Post.aspx?List=90bbfd11-c9a5-45cf-a77e-19559aae81ae&amp;amp;ID=7"&gt;Managing SharePoint with PowerShell&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://cglessner.blogspot.com/2008/06/powershell-sharepoint.html" target=_blank mce_href="http://cglessner.blogspot.com/2008/06/powershell-sharepoint.html"&gt;PowerShell &amp;amp; SharePoint - Quick Start&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://darrinbishop.com/blog/archive/2007/04/08/54.aspx" target=_blank mce_href="http://darrinbishop.com/blog/archive/2007/04/08/54.aspx"&gt;SharePoint and PowerShell Demo&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://www.trentswanson.com/post/2008/01/Calling-SharePoint-web-services-using-Visual-Studio-20082c-WCF2c-and-Windows-Auth.aspx" target=_blank mce_href="http://www.trentswanson.com/post/2008/01/Calling-SharePoint-web-services-using-Visual-Studio-20082c-WCF2c-and-Windows-Auth.aspx"&gt;Calling SharePoint web services using Visual Studio 2008, WCF, and Windows Authentication&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://darrinbishop.com/blog/archive/2007/11/28/psfivefunctions.aspx" target=_blank mce_href="http://darrinbishop.com/blog/archive/2007/11/28/psfivefunctions.aspx"&gt;Five Simple But Powerful PowerShell Functions/Filters for SharePoint&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9029678" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/Windows+SharePoint+Services/default.aspx">Windows SharePoint Services</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/SharePoint+2007/default.aspx">SharePoint 2007</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/Windows+Communication+Foundation/default.aspx">Windows Communication Foundation</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/PowerShell/default.aspx">PowerShell</category></item></channel></rss>