<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IT-Idea</title>
	<atom:link href="http://www.itidea.nl/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.itidea.nl</link>
	<description>All about SharePoint</description>
	<lastBuildDate>Mon, 23 Apr 2012 12:30:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PowerShell Export functions, variables and aliases with wildcards</title>
		<link>http://www.itidea.nl/index.php/powershell-export-functions-variables-and-aliases-with-wildcards/</link>
		<comments>http://www.itidea.nl/index.php/powershell-export-functions-variables-and-aliases-with-wildcards/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 12:30:32 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1406</guid>
		<description><![CDATA[In my previous post &#8216;PowerShell Export-ModuleMember vs Export keys in manifest&#8216; I wrote about ways to export various items from a module.
Trevor Sullivan read my post and suggested in his comment to analyze the use of wildcards to export functions, variables or aliases using the manifest file.
After trying this I got enthusiastic about it, read [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post &#8216;<a href="http://www.itidea.nl/index.php/powershell-export-modulemember-vs-export-keys-in-manifest/">PowerShell Export-ModuleMember vs Export keys in manifest</a>&#8216; I wrote about ways to export various items from a module.</p>
<p>Trevor Sullivan read my post and suggested in his comment to analyze the use of wildcards to export functions, variables or aliases using the manifest file.</p>
<p>After trying this I got enthusiastic about it, read further&#8230;</p>
<p>As well in the manifest file as with the use of Export-ModuleMember in the module wildcards can be used.</p>
<p>This can be (very) helpful when naming the function in the module according to a certain structure.<br />
In C# accessibility levels are used to restrict or limit access to certain methods. There is no such thing in PowerShell, but this can be achieved by (not) exporting the functions from a module. In C# reserved accessibility levels as public and private are used. We can use this &#8216;technique&#8217; in PowerShell by naming the functions in a module according to a standard: use for example -public or _public at the end of a functionname or variable in a module and use the same string literal as wildcard to export functions.</p>
<p>Practically this means defining Export-ModuleMember in the module like:<br />
Export-ModuleMember -Function &#8220;*&#8221;<br />
Export-ModuleMember -Variable &#8220;*&#8221;<br />
Export-ModuleMember -Alias &#8220;*&#8221;<br />
to export all functions, variables and aliases.<br />
Then restrict the exported items in the module manifest like:<br />
FunctionsToExport = &#8216;*-Public&#8217;<br />
VariablesToExport = &#8216;*_Public&#8217;<br />
AliasesToExport = &#8216;*-Public&#8217;</p>
<h3>Module (psm1)</h3>
<pre class="brush: powershell;">
$msgText_Public = 'Hello world!'
$anotherVariable = 'more here'

function Say-HelloWorld() { Write-Host $msgText }
function Calc-Numbers-Public([int] $a,[int] $b) { $a + $b }
function I-Am-Public() { Write-Host &quot;Public&quot; }

Set-Alias Add Calc-Numbers
Set-Alias Hello-Public Say-HelloWorld

Export-ModuleMember -Function &quot;*&quot; #Say-HelloWorld, Calc-Numbers
Export-ModuleMember -Variable &quot;*&quot; #msgText, anotherVariable
Export-ModuleMember -Alias &quot;*&quot;Â  #Hello, Add
</pre>
<h3>Manifest (psd1)</h3>
<pre class="brush: powershell;">
# Functions to export from this module
FunctionsToExport = '*-Public'

# Variables to export from this module
VariablesToExport = '*_Public'

# Aliases to export from this module
AliasesToExport = '*-Public'
</pre>
<p>And the result:</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2012/04/PSModuleImproved1.png"><img class="alignnone size-full wp-image-1411" title="PSModuleImproved" src="http://www.itidea.nl/wp-content/uploads/2012/04/PSModuleImproved1.png" alt="" width="459" height="165" /></a></p>
<h3>Summary</h3>
<p>In my previous post I wrote in the summary:<br />
&#8216;The export keys in the manifest can be seen as an export override of the Export-ModuleMember used in a module&#8230; When trying to control the exports of variables and aliases it all comes clear: export them in the module at all times!&#8217;</p>
<p>After analyzing the wildcard options to export I still agree on the above statements, but I would like to nuance it a bit: export all items in the module and restrict the exported items in the module manifest by using wildcards in the module manifest and using a naming convention when defining functions, variables and aliases.</p>
<p>When approaching exporting the items from a module as described above you can not forget to export a function, variable or alias, you just have to follow this naming convention.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/powershell-export-functions-variables-and-aliases-with-wildcards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Export-ModuleMember vs Export keys in manifest</title>
		<link>http://www.itidea.nl/index.php/powershell-export-modulemember-vs-export-keys-in-manifest/</link>
		<comments>http://www.itidea.nl/index.php/powershell-export-modulemember-vs-export-keys-in-manifest/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 13:46:46 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1385</guid>
		<description><![CDATA[In PowerShell there are two ways to export functions, cmdlets, variables and aliases from a script module file for use by the calling context:
1. By using Export-ModuleMember and specify what resources need to be exported like:
Export-ModuleMember -Function  or Export-ModuleMember -Variable
2. By using a module manifest and specifiy what resources need to be exported like:
@{
&#8230;.
FunctionsToExport [...]]]></description>
			<content:encoded><![CDATA[<p>In PowerShell there are two ways to export functions, cmdlets, variables and aliases from a script module file for use by the calling context:<br />
1. By using Export-ModuleMember and specify what resources need to be exported like:<br />
Export-ModuleMember -Function  or Export-ModuleMember -Variable</p>
<p>2. By using a module manifest and specifiy what resources need to be exported like:<br />
@{<br />
&#8230;.<br />
FunctionsToExport = &#8216; VariablesToExport = &#8221;<br />
&#8230;.<br />
}</p>
<p>By seeing this I got a little confused on which method to use and why: Export-ModuleMember or the manifest way, so it was time to dig into this matter.<br />
By creating a small module, a manifest and a script file the different options can be tested.</p>
<h4>Module (psm1)</h4>
<p>In the module three functions, two with an alias and two variables are defined and exported:</p>
<pre class="brush: powershell;">
$msgText = 'Hello world!'
$anotherVariable = 'more here'

function Say-HelloWorld() { Write-Host $msgText }
function Calc-Numbers([int] $a,[int] $b) { $a + $b }
function I-Am-Private() { Write-Host &quot;private&quot; }

Set-Alias Add Calc-Numbers
Set-Alias Hello Say-HelloWorld

Export-ModuleMember -Function Say-HelloWorld, Calc-Numbers
Export-ModuleMember -Variable msgText, anotherVariable
Export-ModuleMember -Alias Hello, Add
</pre>
<h4>Manifest (psd1)</h4>
<p>The export variables of the manifest are (default) set to &#8216;*&#8217;:</p>
<pre class="brush: powershell;">
# Functions to export from this module
FunctionsToExport = '*'

# Cmdlets to export from this module
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module
AliasesToExport = '*'
</pre>
<h4>Script (ps1)</h4>
<p>The script file imports the module and displays information about the module. This is an excellent way to test what resources are exported:</p>
<pre class="brush: powershell;">
Import-Module ExportFunctions -Force
Get-Module -Name ExportFunctions | fl
</pre>
<h4>Tests</h4>
<p>Running this script results in the following output:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules01.png"><img class="size-full wp-image-1388 alignnone" title="PSModules01" src="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules01.png" alt="" width="457" height="166" /></a></p>
<p>As can be seen two functions, the aliases and variables are exported as defined in Export-ModuleMember in the module.</p>
<p>The Export-ModuleMembers lines are now removed to test the default settings in the manifest file (all &#8216;*&#8217; for the export keys). Running the same script now results in:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules02.png"><img class="alignnone size-full wp-image-1389" title="PSModules02" src="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules02.png" alt="" width="532" height="170" /></a></p>
<p>All the functions are exported, but none of the alias or variables. At first sight this seems a bit strange, because the generated comment of the export keys of the manifest say &#8216; to export from this module&#8217;. This seems only the case for the functions.</p>
<p><a href="http://technet.microsoft.com/en-us/library/dd878297%28v=VS.85%29.aspx">TechNet </a>documentation for FunctionsToExport key:</p>
<blockquote><p>Specifies the functions that the module exports (wildcard characters are permitted) to the callerâ€™s session state. By default, all functions are exported. You can use this key to restrict the functions that are exported by the module&#8230;</p></blockquote>
<p>And the TechNet documentation for VariableToExport key:</p>
<blockquote><p>Specifies the variables that the module exports (wildcard characters are permitted) to the callerâ€™s session state. By default, all variables are exported. You can use this key to restrict the variables that are exported by the module&#8230;</p></blockquote>
<p>The statement don&#8217;t differ, but the behavior is.</p>
<h5>The &#8216;*&#8217; at the FunctionsToExport key means the restriction is:</h5>
<p><span style="text-decoration: underline;">If Export-ModuleMember -Function in the module is used, the functions listed there are exported:</span><br />
In module:</p>
<pre class="brush: powershell;">Export-ModuleMember -Function Say-HelloWorld, Calc-Numbers</pre>
<p>In manifest:</p>
<pre class="brush: powershell;">FunctionsToExport = '*'</pre>
<p>Result:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules03.png"><img class="alignnone size-full wp-image-1390" title="PSModules03" src="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules03.png" alt="" width="412" height="179" /></a></p>
<p><span style="text-decoration: underline;"> If Export-ModuleMember -Function is NOT used in the module and in manifest &#8216;*&#8217; is used all functions are exported: </span><br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules03a.png"><img class="alignnone size-full wp-image-1391" title="PSModules03a" src="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules03a.png" alt="" width="532" height="170" /></a></p>
<h5>The &#8216;*&#8217; at the VariablesToExport key means: By default none of the variables are exported, unless variables are exported by the Export-ModuleMember in the module.</h5>
<p>In module: No Export-ModuleMember -Variable<br />
In manifest:</p>
<pre class="brush: powershell;">VariablesToExport = '*'</pre>
<p>Result:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules04.png"><img class="alignnone size-full wp-image-1392" title="PSModules04" src="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules04.png" alt="" width="421" height="175" /></a></p>
<p>In module: No Export-ModuleMember -Variable<br />
In manifest:</p>
<pre class="brush: powershell;">VariablesToExport = 'anotherVariable'</pre>
<p>Result:<br />
<a href="../wp-content/uploads/2012/03/PSModules04.png"><img title="PSModules04" src="../wp-content/uploads/2012/03/PSModules04.png" alt="" width="421" height="175" /></a></p>
<p>In module:</p>
<pre class="brush: powershell;">Export-ModuleMember -Variable msgText, anotherVariable</pre>
<p>In manifest:</p>
<pre class="brush: powershell;">VariablesToExport = '*'</pre>
<p>Result:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules05.png"><img class="alignnone size-full wp-image-1393" title="PSModules05" src="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules05.png" alt="" width="424" height="173" /></a></p>
<p>In module:</p>
<pre class="brush: powershell;">Export-ModuleMember -Variable msgText, anotherVariable</pre>
<p>In manifest:</p>
<pre class="brush: powershell;">VariablesToExport = 'anotherVariable'</pre>
<p>Result:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules06.png"><img class="alignnone size-full wp-image-1394" title="PSModules06" src="http://www.itidea.nl/wp-content/uploads/2012/03/PSModules06.png" alt="" width="423" height="176" /></a></p>
<h3>Summary</h3>
<p>The export keys in the manifest can be seen as an export override of the Export-ModuleMember used in a module. When testing this behavior with functions alone it can be confusing &#8211; at least it confused me &#8211; which method to use &#8211; manifest export key or Export-ModuleMember &#8211; to restrict function exports. When trying to control the exports of variables and aliases it all comes clear: export them in the module at all times!</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/powershell-export-modulemember-vs-export-keys-in-manifest/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Empty tooltip in refinement panel</title>
		<link>http://www.itidea.nl/index.php/empty-tooltip-in-refinement-panel/</link>
		<comments>http://www.itidea.nl/index.php/empty-tooltip-in-refinement-panel/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 11:13:13 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1352</guid>
		<description><![CDATA[Sometimes when hovering over a fieldvalue in the refinementpanel the tooltip displays only &#8216;Refine By:&#8217; without displaying any value.

While another displays an actual value:
Actual term in a tree

or just a &#8216;parent&#8217; term

Why?
When the fieldvalue is less than 19 characters the tooltip stays empty. Well empty.. it displays &#8216;Refine By:&#8217;. Every fieldvalue with more than 19 [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes when hovering over a fieldvalue in the refinementpanel the tooltip displays only &#8216;Refine By:&#8217; without displaying any value.<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/EmptyTooltipRefinementPanel01.png"><img class="alignnone size-full wp-image-1353" title="EmptyTooltipRefinementPanel" src="http://www.itidea.nl/wp-content/uploads/2012/02/EmptyTooltipRefinementPanel01.png" alt="EmptyTooltipRefinementPanel" width="140" height="157" /></a></p>
<p>While another displays an actual value:<br />
Actual term in a tree<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/EmptyTooltipRefinementPanel02.png"><img class="alignnone size-full wp-image-1354" title="Actual term in a tree" src="http://www.itidea.nl/wp-content/uploads/2012/02/EmptyTooltipRefinementPanel02.png" alt="Actual term in a tree" width="248" height="163" /></a></p>
<p>or just a &#8216;parent&#8217; term<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/EmptyTooltipRefinementPanel03.png"><img class="alignnone size-full wp-image-1355" title="Parent term" src="http://www.itidea.nl/wp-content/uploads/2012/02/EmptyTooltipRefinementPanel03.png" alt="Parent term" width="501" height="168" /></a></p>
<h3>Why?</h3>
<p>When the fieldvalue is less than 19 characters the tooltip stays empty. Well empty.. it displays &#8216;Refine By:&#8217;. Every fieldvalue with more than 19 characters is displayed in the tooltip. A &#8216;parent&#8217; term or a whole path.</p>
<h3>How to solve?</h3>
<p>This behavior can be solved by adjusting the xslt.</p>
<p>Original xslt:</p>
<pre class="brush: xml;">
&lt;a href=&quot;{$SecureUrl}&quot; title=&quot;{$RefineByHeading}: {$UrlTooltip}&quot;&gt;
&lt;xsl:value-of select=&quot;Value&quot;/&gt;
&lt;/a&gt;
</pre>
<p>Adjusted xslt:</p>
<pre class="brush: xml;">
&lt;xsl:variable name=&quot;UrlTooltipAdjusted&quot;&gt;
 &lt;xsl:call-template name=&quot;format-tooltip&quot;&gt;
 &lt;xsl:with-param name=&quot;tooltip&quot; select=&quot;$UrlTooltip&quot; /&gt;
 &lt;xsl:with-param name=&quot;string&quot; select=&quot;Value&quot; /&gt;
 &lt;/xsl:call-template&gt;
&lt;/xsl:variable&gt;

&lt;a href=&quot;{$SecureUrl}&quot; title=&quot;{$RefineByHeading}: $UrlTooltipAdjusted}&quot;&gt;
&lt;xsl:value-of select=&quot;Value&quot;/&gt;
&lt;/a&gt;

&lt;xsl:template name=&quot;format-tooltip&quot;&gt;
 &lt;xsl:param name=&quot;tooltip&quot; /&gt;
 &lt;xsl:param name=&quot;string&quot; /&gt;
 &lt;xsl:choose&gt;
 &lt;xsl:when test=&quot;$tooltip != ''&quot;&gt;
 &lt;xsl:value-of select=&quot;$tooltip&quot; /&gt;
 &lt;/xsl:when&gt;
 &lt;xsl:otherwise&gt;
 &lt;xsl:value-of select=&quot;$string&quot; /&gt;
 &lt;/xsl:otherwise&gt;
 &lt;/xsl:choose&gt;
&lt;/xsl:template&gt;
</pre>
<p>The &#8216;format-tooltip&#8217; template checks if the tooltip is empty and replaces the tooltip value with the actual fieldvalue if so.<br />
By doing this the tooltip will never be empty and will always show the value of the fieldvalue.<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/EmptyTooltipRefinementPanel04.png"><img class="alignnone size-full wp-image-1356" title="Tooltip shows value" src="http://www.itidea.nl/wp-content/uploads/2012/02/EmptyTooltipRefinementPanel04.png" alt="Tooltip shows value" width="198" height="153" /></a></p>
<h3>Summary</h3>
<p>Besides the fieldvalues also the tooltip values suffer from a character limitation. The values of the refinement panel have a 19 character display limit, the tooltip doesn&#8217;t display the value when the fieldvalue is less than 19 characters.<br />
This and the <a href="http://www.itidea.nl/index.php/refinement-panel-character-display-limitation/">previous post</a> solve these issues by making minor adjustments to the OOTB xslt.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/empty-tooltip-in-refinement-panel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Refinement panel character display limitation</title>
		<link>http://www.itidea.nl/index.php/refinement-panel-character-display-limitation/</link>
		<comments>http://www.itidea.nl/index.php/refinement-panel-character-display-limitation/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 14:51:39 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1333</guid>
		<description><![CDATA[Search refiners can contain managed metadata fields to refine the results. Sometimes the display mode of the values look a bit weird in the refinement panel.
Suppose a sitecolumn of a library is a managed metadata column bound to a global termset. The termset is the parent of a few terms and all of these terms [...]]]></description>
			<content:encoded><![CDATA[<p>Search refiners can contain managed metadata fields to refine the results. Sometimes the display mode of the values look a bit weird in the refinement panel.</p>
<p>Suppose a sitecolumn of a library is a managed metadata column bound to a global termset. The termset is the parent of a few terms and all of these terms have one or more children itself. A termtree.<br />
The display format of the column is set to &#8216;Display the entire path to the term in the field&#8217;.<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner01.png"><img class="alignnone size-full wp-image-1338" title="Managed metadata column" src="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner01.png" alt="Managed metadata column" width="414" height="397" /></a></p>
<p>A few documents are uploaded to the library and the metadata column is set to one of the terms.<br />
A full crawl is completed and the refinement panel shows the metadata refiner.<br />
The refinement panel now looks like this:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner02.png"><img class="alignnone size-full wp-image-1340" title="Refinement panel with child terms" src="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner02.png" alt="Refinement panel with child terms" width="166" height="147" /></a></p>
<p>As can be seen, not the whole fieldvalue is displayed. That&#8217;s weird. How do I know which one to use if not the whole value can be seen?<br />
Maybe it&#8217;s a css issue or the left column of the screen isn&#8217;t wide enough? Starting up Firebug and checking out the value:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner03.png"><img class="alignnone size-full wp-image-1341" title="Firebug shows value" src="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner03.png" alt="Firebug shows value" width="697" height="171" /></a></p>
<p>The whole value isn&#8217;t present as text to display in the panel! I was seriously surprised!<br />
SharePoint returns only the first 19 characters and three dots&#8230;</p>
<p>But&#8230; hover over de terms and the whole path is displayed. But that&#8217;s not a satisfactory solution, the values have to be displayed properly!</p>
<p>Ok, I agree displaying the whole term tree path isn&#8217;t that useful in this case, but it&#8217;s needed somewhere else in the site, so the display format of the site column has to stay &#8216;Display the entire path to the term in the field&#8217;.<br />
It would be great to have on option to show only the last term value despite the column display format. An excellent configuration place would be an extra attribute in the filter categories definition xml.</p>
<h3>Displaying the last term value</h3>
<p>The xslt of the refinementpanel can be adjusted to display the last term value now we know the tooltip does know the whole value.</p>
<p>Original xslt:</p>
<pre class="brush: xml;">
 &lt;a href=&quot;{$SecureUrl}&quot; title=&quot;{$RefineByHeading}: {$UrlTooltip}&quot;&gt;
  &lt;xsl:value-of select=&quot;Value&quot;/&gt;
 &lt;/a&gt;
</pre>
<p>The new xslt looks a little bit different than that.<br />
First the fieldvalue has to be analyzed if it contains &#8216;:&#8217;. The &#8216;:&#8217; means the value is a child term and the whole tree path is displayed.<br />
From the value which contains the whole tree path the last term is filtered by a recursive xslt template Â´substring-after-lastÂ´.<br />
Then a check has to be performed if the last term value contains the three dots. If it does, the last term value should be taken from the tooltip value, because the xslt Value doesn&#8217;t contain this value. Confusing, isn&#8217;t it?</p>
<pre class="brush: xml;">
&lt;xsl:variable name=&quot;PartOfValue&quot;&gt;
 &lt;xsl:call-template name=&quot;substring-after-last&quot;&gt;
  &lt;xsl:with-param name=&quot;string&quot; select=&quot;Value&quot; /&gt;
  &lt;xsl:with-param name=&quot;delimiter&quot; select=&quot;':'&quot; /&gt;
 &lt;/xsl:call-template&gt;
&lt;/xsl:variable&gt;

&lt;xsl:variable name=&quot;PartOfTooltip&quot;&gt;
 &lt;xsl:call-template name=&quot;substring-after-last&quot;&gt;
  &lt;xsl:with-param name=&quot;string&quot; select=&quot;$UrlTooltip&quot; /&gt;
  &lt;xsl:with-param name=&quot;delimiter&quot; select=&quot;':'&quot; /&gt;
 &lt;/xsl:call-template&gt;
&lt;/xsl:variable&gt;

&lt;xsl:choose&gt;
 &lt;xsl:when test=&quot;($FilterCategoryType = 'Microsoft.Office.Server.Search.WebControls.TaxonomyFilterGenerator') and ($PartOfValue != '')&quot;&gt;
  &lt;xsl:if test=&quot;not(contains($PartOfValue, 'â€¦'))&quot;&gt;
   &lt;xsl:value-of select=&quot;$PartOfValue&quot;/&gt;
  &lt;/xsl:if&gt;
  &lt;xsl:if test=&quot;contains($PartOfValue, 'â€¦')&quot;&gt;
   &lt;xsl:value-of select=&quot;$PartOfTooltip&quot;/&gt;
  &lt;/xsl:if&gt;
 &lt;/xsl:when&gt;
 &lt;xsl:otherwise&gt;
  &lt;xsl:value-of select=&quot;Value&quot;/&gt;
 &lt;/xsl:otherwise&gt;
&lt;/xsl:choose&gt;
</pre>
<p>If the fieldvalue contains less than 19 characters, no dots are displayed and the value can be used, but in that case the urltooltip is empty&#8230; To solve an empty tooltip, check out <a href="http://www.itidea.nl/index.php/empty-tooltip-in-refinement-panel/">my next post</a>.</p>
<p>After the xslt has been implemented the refinementpanel looks like the picture below<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner041.png"><img class="alignnone size-full wp-image-1345" title="Adjusted refinementpanel" src="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner041.png" alt="Adjusted refinementpanel" width="148" height="148" /></a></p>
<p>And the tooltip displays the whole term tree:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner06.png"><img class="alignnone size-full wp-image-1346" title="Tooltip" src="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner06.png" alt="Tooltip" width="256" height="148" /></a></p>
<p>SharePoint returns only the first 19 characters, so what happens when a term itself exists of 19 or more characters?<br />
<a href="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner05.png"><img class="alignnone size-full wp-image-1343" title="Refinement panel with long term" src="http://www.itidea.nl/wp-content/uploads/2012/02/MMDRefiner05.png" alt="Refinement panel with long term" width="201" height="148" /></a></p>
<p>On the one hand it&#8217;s great the 19 character limitation of displaying a whole termtree isn&#8217;t applied to this term, on the other hand, it doesn&#8217;t look very nice when the text continues outside the refinement panel.</p>
<h3>Summary</h3>
<p>The values of the refinement panel have a 19 character display limit. When displaying a whole termtree it&#8217;s likely this limitation will be exceeded. Just a few xslt adjustments are necessary to display the fieldvalues correct again.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/refinement-panel-character-display-limitation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ever tried to update a user subtype from code?</title>
		<link>http://www.itidea.nl/index.php/ever-tried-to-update-a-user-subtype-from-code/</link>
		<comments>http://www.itidea.nl/index.php/ever-tried-to-update-a-user-subtype-from-code/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 12:57:31 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1324</guid>
		<description><![CDATA[User subtypes are one of the many new and nice things in SharePoint 2010.
The other day I was editing user profiles and changed the subtype for this profile in code. After changing the user subtype Commit() was called and I thought I was done.
But then it just started, because the user profile wasn&#8217;t updated at [...]]]></description>
			<content:encoded><![CDATA[<p>User subtypes are one of the many new and nice things in SharePoint 2010.<br />
The other day I was editing user profiles and changed the subtype for this profile in code. After changing the user subtype Commit() was called and I thought I was done.<br />
But then it just started, because the user profile wasn&#8217;t updated at all. No exception, no message at all, just the old user subtype.<br />
The used code:</p>
<pre class="brush: csharp;">
ProfileSubtypeManager psubm = ProfileSubtypeManager.Get(context);
ProfileSubtype newSubtype = psubm.GetProfileSubtype(newSubtypeName);
currentUserProfile.ProfileSubtype = newSubtype;
currentUserProfile.Commit();
</pre>
<p>Changing the user subtype in the UI really updated the setting, so it was time to debug the SharePoint UserProfiles assembly.<br />
The short version of what the debugging session(s) told me:<br />
A UserProfileUpdateWrapper was created with the following xml</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
&lt;MSPROFILE&gt;
 &lt;PROFILE ProfileName=&quot;UserProfile&quot;&gt;
 &lt;USER NewUser=&quot;0&quot; NTAccount=&quot;account&quot; UserID=&quot;3db01e67-abb0-4946-8fa8-85943768cb79&quot;&gt;
</pre>
<p>The next step is iterating through the user profile fields to check if the value &#8216;IsDirty&#8217; aka the value has been changed. This is the only trigger to actually update a user profile.<br />
When adjusting the user subtype from the UI a few properties are updated, even when they&#8217;re not changed. The final XML looks like the following:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
&lt;MSPROFILE&gt;
 &lt;PROFILE ProfileName=&quot;UserProfile&quot;&gt;
 &lt;USER NewUser=&quot;0&quot; NTAccount=&quot;account&quot; UserID=&quot;3db01e67-abb0-4946-8fa8-85943768cb79&quot;&gt;
 &lt;PROPERTY PropertyName=&quot;Assistant&quot; Privacy=&quot;1&quot; PropertyValue=&quot;&quot; /&gt;
 &lt;PROPERTY PropertyName=&quot;PictureURL&quot; Privacy=&quot;1&quot; PropertyValue=&quot;&quot; /&gt;
 &lt;PROPERTY PropertyName=&quot;SPS-TimeZone&quot; Privacy=&quot;1&quot; PropertyValue=&quot;&quot; /&gt;
 &lt;/USER&gt;
 &lt;/PROFILE&gt;
&lt;/MSPROFILE&gt;
</pre>
<p>and a real update of the user profile occurred.</p>
<p>To make the update work from code appearently another property has to be updated together with the change of subtype. After a test with an update of a random property, the user subtype was updated too.</p>
<h3>Summary</h3>
<p>Changing only the user subtype from code, does trigger the Commit() method, but doesn&#8217;t call the update profile, because no user profile property was changed. Use a dummy property to update every time the user subtype has changed.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/ever-tried-to-update-a-user-subtype-from-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to delete crawled properties</title>
		<link>http://www.itidea.nl/index.php/how-to-delete-crawled-properties/</link>
		<comments>http://www.itidea.nl/index.php/how-to-delete-crawled-properties/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 16:42:56 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1311</guid>
		<description><![CDATA[You all know by now how to delete crawled properties and that you&#8217;re not able to delete a single crawled property. When deleting crawled properties, all unmapped properties from a single category get deleted.

In Central Administration select &#8216;Manage service applications&#8217;
Select the Search Service Application
Select &#8216;Metadata properties&#8217;
Select &#8216;Categories&#8217;
Edit the category of your choice
Select &#8216;Delete all unmapped [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesDatabase.png"></a>You all know by now how to delete crawled properties and that you&#8217;re not able to delete a single crawled property. When deleting crawled properties, all unmapped properties from a single category get deleted.</p>
<ol>
<li>In Central Administration select &#8216;Manage service applications&#8217;</li>
<li>Select the Search Service Application</li>
<li>Select &#8216;Metadata properties&#8217;</li>
<li>Select &#8216;Categories&#8217;</li>
<li>Edit the category of your choice</li>
<li>Select &#8216;Delete all unmapped crawled properties&#8217;</li>
<li>Select &#8216;Ok&#8217;</li>
</ol>
<p>First thing to notice here: it deletes only <em>unmapped</em> crawled properties. So if your crawled property is still mapped, remove this first.</p>
<p>Second thing: make sure the crawled property isn&#8217;t included in the index!</p>
<p>First there are two crawled properties in the SharePoint category (well, there are more, I selected two to see the difference&#8230;) :<br />
<a href="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesBothPresent.png"><img class="alignnone size-full wp-image-1312" title="CrawledPropertiesBothPresent" src="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesBothPresent.png" alt="" width="570" height="77" /></a></p>
<p>One is included in the index, the other isn&#8217;t.<br />
Next step is to clear the SharePoint category by following all the steps above. The result:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesOnePresent.png"><img class="alignnone size-full wp-image-1313" title="CrawledPropertiesOnePresent" src="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesOnePresent.png" alt="" width="570" height="55" /></a></p>
<p>The crawled property included in the index is still present! Even if a full index reset has been performed and the category has beenÂ cleaned up, theÂ crawled properties doesn&#8217;t get deleted when &#8216;Included in index&#8217; is set to &#8216;Yes&#8217;.</p>
<h3>Summary</h3>
<p>Besides unmapping a crawled property, deselect &#8216;Included in index&#8217; in the crawled property&#8217;s properties to delete a crawled property.</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesIncludeInIndexSetting.png"><img class="alignnone size-full wp-image-1314" title="CrawledPropertiesIncludeInIndexSetting" src="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesIncludeInIndexSetting.png" alt="" width="640" height="174" /></a></p>
<p>This is a valid and working solution for the most of the crawled properties and certainly your custom ones.</p>
<p>When you&#8217;re going to test this youself, you&#8217;ll notice some of the OOTB unmapped and not include in the indexÂ crawled properties will still be present after performing the steps above. This is the case because SharePointÂ uses some hidden managed properties which are mapped to these crawled properties. Steve Curran explains this<a href="http://vspug.com/smc750/2008/10/10/unable-to-delete-unmapped-crawled-properties-in-sharepoint-search/"> in his post </a><a href="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesDatabase.png"></a>which was written for MOSS 2007, but the same principle is still valid for SharePoint 2010:</p>
<p>In table MSSCrawledProperties ows_BaseName can be found with CrawledPropertyId 192.<br />
In table MSSSchemaPropertyMappings CrawledPropertyId 192 is mapped to PID 2147418032.<br />
In table MSSManagedProperties PID 2147418032 is mapped to property TempTitle with &#8216;Hidden&#8217; and &#8216;NoDelete&#8217; set to 1:</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesDatabase2.png"><img class="alignnone size-full wp-image-1317" title="CrawledPropertiesDatabase" src="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesDatabase2.png" alt="" width="828" height="32" /></a><a href="http://www.itidea.nl/wp-content/uploads/2011/11/CrawledPropertiesDatabase1.png"></a></p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/how-to-delete-crawled-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Foreach vs ForEach-Object</title>
		<link>http://www.itidea.nl/index.php/powershell-foreach-vs-foreach-object/</link>
		<comments>http://www.itidea.nl/index.php/powershell-foreach-vs-foreach-object/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 16:46:57 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1303</guid>
		<description><![CDATA[There are two variants of &#8216;for each&#8217; in PowerShell:
Foreach statement: iterates over a collection of objects
ForEach-Object: obtains its entries from the pipeline
At first they both seemed to do the job, but there are some differences.
Let&#8217;s do a test with a simple array of items and loop through it using both foreach methods. To measure the [...]]]></description>
			<content:encoded><![CDATA[<p>There are two variants of &#8216;for each&#8217; in PowerShell:<br />
Foreach statement: iterates over a collection of objects<br />
ForEach-Object: obtains its entries from the pipeline</p>
<p>At first they both seemed to do the job, but there are some differences.<br />
Let&#8217;s do a test with a simple array of items and loop through it using both foreach methods. To measure the time elapsed to loop the array the Measure-Command is used.</p>
<pre class="brush: powershell;">

$items = 1,2,3,4,5,6,7,8,9,0,10,12,13,14,15,52,58,41,59,841,5,4,1

Write-Host &quot;ForEach-Object: &quot;
(Measure-Command {Â  `
Â $items | ForEach-Object { `
Â Â &quot;Item: $_&quot; `
Â }}).totalmilliseconds

Write-Host &quot;Foreach: &quot;
(Measure-Command {Â  `
Â Foreach ($item in $items) { `
Â Â &quot;Item: $element&quot; `
Â }}).totalmilliseconds
</pre>
<p>MultipleÂ results:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2011/11/ForEach.png"><img class="alignnone size-full wp-image-1306" title="ForEach" src="http://www.itidea.nl/wp-content/uploads/2011/11/ForEach.png" alt="" width="130" height="407" /></a></p>
<p>The results differ a lot!</p>
<h3>
When to use which method?</h3>
<p>When the items of the array are known at forehand, like in the test, foreach is the better approach because of the speed. This kind of speed can only be reached when all the objects are already known and stored in a variable.</p>
<p>ForEach-Object is a different story. When the items have to be collected before the loop starts and this can take a while: use ForEach-Object.<br />
This method processes the objects collected in the array directly when available and doesn&#8217;t wait until all objects are collected.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/powershell-foreach-vs-foreach-object/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SPHttpUtility vs HTTPUtility</title>
		<link>http://www.itidea.nl/index.php/sphttputility-vs-httputility/</link>
		<comments>http://www.itidea.nl/index.php/sphttputility-vs-httputility/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 09:07:45 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1280</guid>
		<description><![CDATA[Comparison between SPHttpUtility and HTTPUtility &#8211; encoding and decoding
There are different ways of encoding and decoding querystring parameters, for example by using SPHttpUtility or HttpUtility.
While programming SharePoint I always tend to use the SPHttpUtility class, but I didn&#8217;t know exactly why. Until I accidentally used the HttpUtility and SPHttpUtility at the same time:Â I noticed some [...]]]></description>
			<content:encoded><![CDATA[<h3>Comparison between SPHttpUtility and HTTPUtility &#8211; encoding and decoding</h3>
<p>There are different ways of encoding and decoding querystring parameters, for example by using SPHttpUtility or HttpUtility.<br />
While programming SharePoint I always tend to use the SPHttpUtility class, but I didn&#8217;t know exactly why. Until I accidentally used the HttpUtility and SPHttpUtility at the same time:Â I noticed some differences.Â Â </p>
<h3>Encode</h3>
<p>SharePoint has a Utilities namespace, Microsoft.SharePoint.Utilities, which provides the SPHttpUtility class. One of the methods in this class is UrlKeyValueEncode with several overloads.<br />
The description of the methodÂ </p>
<pre class="brush: csharp;">UrlKeyValueEncode(string keyOrValueToEncode)</pre>
<p>is &#8216;Encodes the specified URL query string key or value&#8217;.Â </p>
<p>The HttpUtility class in the namespace System.Web contains a method UrlEnode, also with overloads. The description of</p>
<pre class="brush: csharp;">UrlEncode(string str)</pre>
<p>is &#8216;Encodes a URL string&#8217;.<br />
The HttpUtility class doesn&#8217;t have a method to encode a query string key or value as UrlKeyValueEncode, but this is the best match.Â Â </p>
<p>Let&#8217;s encode a space:<br />
The result while encoding with HttpUtility is &#8216;+&#8217;, encoding with SPHttpUtility results in a &#8216;%20&#8242;.</p>
<p>One of the major differences is the casing of the encoded characters. SPHttpUtility encodes the characters uppercase, HttpUtility lowercase.<br />
Another difference can be seen in the picture below: HttpUtility doesn&#8217;t encode all characters, SPHttpUtility does:Â Â </p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/11/Encoding01.png"><img class="alignnone size-full wp-image-1283" title="Encoding01" src="http://www.itidea.nl/wp-content/uploads/2011/11/Encoding01.png" alt="" width="642" height="219" /></a>Â Â </p>
<h3>Decode</h3>
<p>To decode charactersÂ the SPHttpUtility class provides the method</p>
<pre class="brush: csharp;">UrlKeyValueDecode(string keyOrValueToDecode)</pre>
<p>The couterpart of the UrlEncode method in the HttpUtility class is</p>
<pre class="brush: csharp;">UrlDecode(string str)</pre>
<p>While encoding results in different outcome, decoding doesn&#8217;t.<br />
As can be seen in the picture of the encoded characters above, HttpUtility doesn&#8217;t encode e.g. &#8216;(&#8216;, &#8216;!&#8217;, &#8216;*&#8217;. When decoding these (unencoded) characters with SPHttpUtility the results stay &#8216;(&#8216;, &#8216;!&#8217;, &#8216;*&#8217;. Check the pictures below.<br />
Encoded with HttpUtility, decoded these characters:Â Â </p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/11/Encoding021.png"><img class="alignnone size-full wp-image-1284" title="Encoding021" src="http://www.itidea.nl/wp-content/uploads/2011/11/Encoding021.png" alt="" width="638" height="218" /></a></p>
<p>SPHttpUtility encodes characters &#8216;(&#8216;, &#8216;!&#8217; and &#8216;*&#8217; as &#8216;%28&#8242;, &#8216;%21&#8242; and &#8216;%2A&#8217;. When decoding these characters with SPHttpUtility, but also with HttpUtility, the results are the same:Â Â </p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/11/Encoding022.png"><img class="alignnone size-full wp-image-1285" title="Encoding022" src="http://www.itidea.nl/wp-content/uploads/2011/11/Encoding022.png" alt="" width="644" height="222" /></a>Â Â </p>
<h3>Summary</h3>
<p>Since decoding gives the same results with SPHttpUtility and HttpUtility, why bother the encoding method?Â Â </p>
<p>Well, something inside me tells me SharePoint is using it somewhere internally. I didn&#8217;t figure out where, but why is the SPHttpUtility implemented if SharePoint easily could use HttpUtility?<br />
Besides some feelings, the SPHttpUtility doesn&#8217;t use HttpUtility internally. When checking out the SPHttpUtility.UrlKeyValueEncode with ILSpy, the encoded values, uppercase(!), are listed is the readonly string array s_crgstrUrlHexValue.</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/11/EncodingILSpy.png"><img class="alignnone size-full wp-image-1286" title="EncodingILSpy" src="http://www.itidea.nl/wp-content/uploads/2011/11/EncodingILSpy.png" alt="" width="605" height="498" /></a>Â Â </p>
<p>Wikipedia has a definition of percent encoding (<a href="http://en.wikipedia.org/wiki/Percent-encoding">http://en.wikipedia.org/wiki/Percent-encoding</a>) :<br />
&#8216;Percent-encoding, also known as URL encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI) under certain circumstances&#8217;Â Â </p>
<p>According to this article reserved characters (Reserved characters are those characters that sometimes have special meaning) must be encoded&#8230;<br />
According to RFC 3986 reserved characters are:</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/11/EncodingRFC3986.png"><img class="alignnone size-full wp-image-1287" title="EncodingRFC3986" src="http://www.itidea.nl/wp-content/uploads/2011/11/EncodingRFC3986.png" alt="" width="388" height="59" /></a></p>
<p>And encoded:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2011/11/EncodingRFC3986Encoded.png"><img class="alignnone size-full wp-image-1288" title="EncodingRFC3986Encoded" src="http://www.itidea.nl/wp-content/uploads/2011/11/EncodingRFC3986Encoded.png" alt="" width="677" height="91" /></a>Â Â </p>
<p>So HttpUtility doesn&#8217;t encode the first five characters, SPHttpUtility encodes all reserved characters.Â Â </p>
<p>To be compatible with 3986 standard it seems SPHttpUtility is the best option to use.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/sphttputility-vs-httputility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to retrieve document set version history</title>
		<link>http://www.itidea.nl/index.php/how-to-retrieve-document-set-version-history/</link>
		<comments>http://www.itidea.nl/index.php/how-to-retrieve-document-set-version-history/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 09:48:30 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1265</guid>
		<description><![CDATA[Document set versions are slightly different than item versions. Document sets can be managed by a separate ribbon tab called Document Set and group called Manage.

To create a version of a document set the action Capture Version in this part of the ribbon has to be selected. When selecting the following screen will be shown:

To [...]]]></description>
			<content:encoded><![CDATA[<p>Document set versions are slightly different than item versions. Document sets can be managed by a separate ribbon tab called Document Set and group called Manage.<br />
<a href="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory01Ribbon.png"><img class="alignnone size-full wp-image-1272" title="DocSetHistory01Ribbon" src="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory01Ribbon.png" alt="" width="467" height="137" /></a></p>
<p>To create a version of a document set the action Capture Version in this part of the ribbon has to be selected. When selecting the following screen will be shown:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory02Version.png"><img class="alignnone size-full wp-image-1273" title="DocSetHistory02Version" src="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory02Version.png" alt="" width="613" height="377" /></a></p>
<p>To use versioning of a document set (and items) versioning has to be enabled on the library.Â Â Â Â </p>
<p>After selecting a version option (when major/minor enabled), adding some comment and selecting the Ok button a document set version is created. To view the versions of the document set the action Version History can be selected in the ribbon.<br />
<a href="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory03VersionHistory.png"><img class="alignnone size-full wp-image-1274" title="DocSetHistory03VersionHistory" src="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory03VersionHistory.png" alt="" width="508" height="374" /></a></p>
<p>In this screen the first column displayed is No. This is not the regular version column of the library, but a totally different one. When creating a document set version the version column of the library doesn&#8217;t change, only the No value.Â Â Â Â </p>
<p>That&#8217;s nice, but where is the version of the document set actually stored?Â Â Â Â </p>
<p>The version(s) of a document set are stored in the propertybag of the item itself.Â Â Â Â </p>
<p>To analyze settings I always start up PowerShell first to check on things. Just because it&#8217;s quick and easy. When I get what I want from PowerShell it&#8217;s easily turned into C# code. I followed the same procedure to get to the storage of document set versions. Since I couldn&#8217;t find the version anywhere in the UI, my first guess was checking the propertybag keys.Â Â Â Â </p>
<pre class="brush: powershell;">
$site=Get-SPSite &quot;http://sp2010dev&quot;
$docList = $site.RootWeb.Lists.TryGetList(&quot;Documents&quot;);
$item = $docList.Items.GetItemById(2)
$prop = $item.Properties
</pre>
<p>Often I use PowerGui Script Editor which gives an excellent overview of variables:Â Â Â Â </p>
<p>The keys:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory04ItemKeys.png"><img class="alignnone size-full wp-image-1275" title="DocSetHistory04ItemKeys" src="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory04ItemKeys.png" alt="" width="522" height="406" /></a></p>
<p>And the values:<br />
<a href="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory05ItemValues.png"><img class="alignnone size-full wp-image-1276" title="DocSetHistory05ItemValues" src="http://www.itidea.nl/wp-content/uploads/2011/08/DocSetHistory05ItemValues.png" alt="" width="648" height="344" /></a></p>
<p>While scrolling through the property keys I noticed a key named snapshots. By checking out the value of that key I knew I found it!Â Â Â Â </p>
<p>The following PowerShell command can be used to get the value of the snapshot key:Â Â Â Â </p>
<pre class="brush: powershell;">
$item.Properties.get_Item(&quot;snapshots&quot;)
</pre>
<p>The version history is stored in xml:Â Â Â Â </p>
<pre class="brush: xml;">
&lt;SnapshotCollection NextSnapshotNumber=&quot;3&quot; NextInternalId=&quot;1&quot;&gt;
  &lt;Items /&gt;
  &lt;Snapshots&gt;
    &lt;Snapshot Label=&quot;2&quot; Major=&quot;True&quot; Created=&quot;08/21/2011 07:50:56&quot; By=&quot;username&quot;&gt;
      &lt;Comments&gt;Another version of the document set.&lt;/Comments&gt;
      &lt;Fields&gt;
        &lt;Field Id=&quot;8553196d-ec8d-4564-9861-3dbe931050c8&quot;&gt;Document set name&lt;/Field&gt;
        &lt;Field Id=&quot;fa564e0f-0c70-4ab9-b863-0177e6ddd247&quot;&gt;Document set name&lt;/Field&gt;
        &lt;Field Id=&quot;cbb92da4-fd46-4c7d-af6c-3128c2a5576e&quot;&gt;Add a description here.&lt;/Field&gt;
      &lt;/Fields&gt;
      &lt;SnapshotItems /&gt;
    &lt;/Snapshot&gt;
    &lt;Snapshot Label=&quot;1&quot; Major=&quot;True&quot; Created=&quot;08/21/2011 07:50:20&quot; By=&quot;username&quot;&gt;
      &lt;Comments&gt;This is the first version of this document set.&lt;/Comments&gt;
      &lt;Fields&gt;
        &lt;Field Id=&quot;8553196d-ec8d-4564-9861-3dbe931050c8&quot;&gt;Document set name&lt;/Field&gt;
        &lt;Field Id=&quot;fa564e0f-0c70-4ab9-b863-0177e6ddd247&quot;&gt;Document set name&lt;/Field&gt;
        &lt;Field Id=&quot;cbb92da4-fd46-4c7d-af6c-3128c2a5576e&quot; /&gt;
      &lt;/Fields&gt;
      &lt;SnapshotItems /&gt;
    &lt;/Snapshot&gt;
  &lt;/Snapshots&gt;
&lt;/SnapshotCollection&gt;
</pre>
<p>Â Â Â </p>
<p>The Snapshot element with Label attribute 1 is the first version. The comment is displayed and the fields and values of the document set.Â Â Â Â </p>
<p>The Snapshot element with Label attribute 2 is the second version. The same items are displayed with the addition of the value of the description â€˜Add a description hereâ€™. Thatâ€™s what I changed before creating the second version.Â Â Â Â </p>
<p>The attribute NextSnapshotNumber holds the value of the version number that will be created when creating another version, 3 in this case.Â Â Â Â </p>
<h3>SummaryÂ Â </h3>
<p>Document set versions are different than regular item versions. The version history of a document set is stored in the propertybag of the document set itself as xml.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/how-to-retrieve-document-set-version-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell &#8211; Choose between colored host text or write to an output file? Not anymore!</title>
		<link>http://www.itidea.nl/index.php/powershell-choose-between-colored-host-text-or-write-to-an-output-file-not-anymore/</link>
		<comments>http://www.itidea.nl/index.php/powershell-choose-between-colored-host-text-or-write-to-an-output-file-not-anymore/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 13:06:10 +0000</pubDate>
		<dc:creator>Anita</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.itidea.nl/?p=1228</guid>
		<description><![CDATA[In PowerShell multiple Write statements are available. The two statements I want to address are Write-Host and Write-Output.Â 
What do these two do?
Write-Host: Writes customized output to a host
Write-Output: Sends the specified objects to the next command in the pipeline. If the command is the last command in the pipeline, the objects are displayed in the [...]]]></description>
			<content:encoded><![CDATA[<p>In PowerShell multiple Write statements are available. The two statements I want to address are Write-Host and Write-Output.Â </p>
<p>What do these two do?<br />
<em>Write-Host</em>: Writes customized output to a host<br />
<em>Write-Output</em>: Sends the specified objects to the next command in the pipeline. If the command is the last command in the pipeline, the objects are displayed in the consoleÂ </p>
<p>An example of Write-Host</p>
<pre class="brush: powershell;">
Write-Host &quot;Write-Host statement...&quot;
</pre>
<p>The result displayed in the hostÂ </p>
<p>Â <a href="http://www.itidea.nl/wp-content/uploads/2011/07/PSWrite0.png"><img class="size-full wp-image-1230 alignnone" title="PSWrite0" src="http://www.itidea.nl/wp-content/uploads/2011/07/PSWrite0.png" alt="" width="199" height="41" /></a></p>
<p>An example of Write-Output</p>
<pre class="brush: powershell;">
Write-Output &quot;Write-Output statement...&quot;
</pre>
<p>The result displayed in the host</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/07/PSWrite00.png"><img class="size-full wp-image-1231 alignnone" title="PSWrite00" src="http://www.itidea.nl/wp-content/uploads/2011/07/PSWrite00.png" alt="" width="215" height="44" /></a>Â </p>
<p>At this point there is no difference in the result of these two statements.Â </p>
<h3>Write-Host with ForegroundColorÂ </h3>
<p>A nice parameter of Write-Host is -ForegroundColor. Using this parameter with a color, the text displayed in the host has the color specified. I find this very useful to quickly see if a script hasÂ succeeded or failed. I always display the success message in green, the failed message in red.Â Â Â </p>
<p>To show this the existence of a SPList will be checked. If it doesnÂ´t exist, it will be created using the following statement:Â Â Â </p>
<pre class="brush: powershell;">
$sampleListName = &quot;PS List&quot;
$siteUrl=http://sp2010dev
$site = Get-SPSite $siteUrl
$web = $site.RootWeb&lt;/pre&gt;

function CreateList($listName){
  $web.Lists.Add($listName, &quot;Description for list&quot;, [Microsoft.SharePoint.SPListTemplateType]::GenericList)
}

function CheckIfListExists(){
$currentList = $web.Lists.TryGetList($sampleListName)
  if($currentList -ne $null){
    Write-Host &quot;List exists&quot; -ForegroundColor Green
  }
  else{
    Write-Host &quot;List doesn't exist, creating now...&quot; -ForegroundColor Red
    CreateList $sampleListName
    Write-Host &quot;Check if list exist...&quot;
    CheckIfListExists
  }
}

Write-Host &quot;Calling CheckIfListExists ...&quot;
CheckIfListExists
</pre>
<p>If the list exists a message with green colored text will appear: &#8216;List exists&#8217;, else a message with red colored text will appear: &#8216;List doesn&#8217;t exist, creating now&#8230;&#8217;, followed by the actualÂ creation of the list. After this the existence of the list is check again. As you can see if the list creation fails the code will be stuck in an infinite loop, so donÂ´t use this as production code&#8230;Â Â Â </p>
<p>Outcome when the list doesnÂ´t exist and is created:</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite01.png"><img class="alignnone size-full wp-image-1244" title="PSWrite01" src="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite01.png" alt="" width="310" height="78" /></a></p>
<p>Outcome when the list already exists:&lt;picture PSWrite02&gt;</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite02.png"><img class="alignnone size-full wp-image-1245" title="PSWrite02" src="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite02.png" alt="" width="252" height="34" /></a></p>
<h3>Write-Output with output to fileÂ Â Â </h3>
<p>A nice option of Write-Output is the possibility to write the output to a file on the filesystem.Â Â Â </p>
<pre class="brush: powershell;">
$file = &quot;C:\_Tools\OutputFile.txt&quot;
Write-Output &quot;Write-Output statement...&quot;
Write-Output &quot;Write-Output statement...&quot; | Out-File $file
</pre>
<p>The first Write-Output statement writes the output to the host, the second to the file (but not to the host).Â Â Â </p>
<h3>Best of both worlds?Â Â Â </h3>
<p>Ofcourse Write-Host as well as Write-Output has a lot more options to use, but I want to point out something here.<br />
Write-Host can write colored messages to the host, but it can&#8217;t write output to a file.<br />
Write-Output can&#8217;t write colored messages to the host, but it can write output to a file.Â Â Â </p>
<p>What if I want to:Â Â Â </p>
<p>write colored messages to the host if I decide to output to the host AND<br />
write messages to a file just by using &#8216;| Out-File $file&#8217;</p>
<p>With the current possibilities of both operations I have to choose between:<br />
1. colored messages (and nothing written to the output file) or put the output to a file and host, but no colored messages displayed in the hostÂ<br />
2. write double statements; Write-Host with -ForeGroundColor to write the colored output to the host and Write-Output to write the output to a file when using &#8216;| Out-File $file&#8217;.Â Â Â </p>
<p>Let me clarify the second option with an example.</p>
<pre class="brush: powershell;">
Write-Output &quot;Write-Output statement...&quot; | Out-File $file
Write-Host &quot;Write-Host statement...&quot; -ForegroundColor Blue
</pre>
<p>Write-Output writes the message to the file specified in $file and is not written to the host.<br />
Write-Host writes the message to the host in the color blue.<br />
Just as expected and just want I wanted. But I have to write the messages twice.</p>
<p>Another option:Â Â Â </p>
<pre class="brush: powershell;">
Write-Output &quot;Write-Output statement...&quot;
Write-Host &quot;Write-Host statement...&quot; -ForegroundColor Blue
</pre>
<p>The code above is saved in a file and called by:Â Â Â </p>
<pre class="brush: powershell;">

PS C:\_Tools&gt; .\PSScriptFile.ps1
</pre>
<p>Result: messages appear twice in the host.</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite031.png"><img class="alignnone size-full wp-image-1254" title="PSWrite03" src="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite031.png" alt="" width="209" height="38" /></a></p>
<p>Output it to a file:Â Â Â </p>
<pre class="brush: powershell;">

PS C:\_Tools&gt; .\PSScriptFile.ps1 | Out-File $file
</pre>
<p>Result: No message in the host, but a message in the file!<br />
Still, the messages have to be written twice in the file: Write-Host and Write-Output&#8230;<br />
Do I really have to write all the messages twice to show them colored in the host and write them to an output file?<br />
Actually, there is no possibility to make Write-Host write to an output file.<br />
But the host itself can be accessed to change its text color (and more) and use Write-Output to write to the host (in color!) and to an output file.</p>
<p>The host itself can be accessed by $Host.Â Â Â </p>
<pre class="brush: powershell;">

$Host.Name
</pre>
<p>When using PowerGUI Script Editor the results of the above statement is: PowerGUIScriptEditorHost<br />
Executing the same statement in the console the result is: ConsoleHost</p>
<p>That&#8217;s awesome, $Host knows who he is! <img src='http://www.itidea.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Let&#8217;s try to get the text color of the host:</p>
<pre class="brush: powershell;">

$currentColor = $Host.UI.RawUI.ForegroundColor
</pre>
<p>PowerGUI Script Editor:</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite04.png"><img class="alignnone size-full wp-image-1248" title="PSWrite04" src="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite04.png" alt="" width="249" height="23" /></a></p>
<p>Console:</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite05.png"><img class="alignnone size-full wp-image-1249" title="PSWrite05" src="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite05.png" alt="" width="621" height="45" /></a></p>
<p>So what about changing the text color of the host?Â Â Â </p>
<pre class="brush: powershell;">

function WriteCustomOutput($message, [System.ConsoleColor]$foregroundcolor)
{
  currentColor = $Host.UI.RawUI.ForegroundColor
  $Host.UI.RawUI.ForegroundColor = $foregroundcolor
  if ($message)
  {
    Write-Output $message
  }
  $Host.UI.RawUI.ForegroundColor = $currentColor
}

WriteCustomOutput -message &quot;WriteColoredOutput statement...&quot; -foregroundcolor Green
</pre>
<p>And the result in the host:</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite06.png"><img class="alignnone size-full wp-image-1250" title="PSWrite06" src="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite06.png" alt="" width="271" height="41" /></a>Â Â Â </p>
<p>Let&#8217;s save the code to a file and call the file from the console:</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite07.png"><img class="alignnone size-full wp-image-1251" title="PSWrite07" src="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite07.png" alt="" width="321" height="43" /></a>Â </p>
<p>And will the output be written to an output file when using the statement:</p>
<pre class="brush: powershell;">

.\PSWriteCustomOutput.ps1 | Out-File OutputFile.txt
</pre>
<p>Yes it is written to the file:</p>
<p><a href="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite08.png"><img class="alignnone size-full wp-image-1252" title="PSWrite08" src="http://www.itidea.nl/wp-content/uploads/2011/08/PSWrite08.png" alt="" width="282" height="77" /></a>Â Â Â </p>
<h3>Summary</h3>
<p>Write-Host and Write-Output are very simple and useful statements. Sometimes the best of both is wished for.<br />
With some creativity you can have both. Use WriteCustomOutput!</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.itidea.nl/index.php/powershell-choose-between-colored-host-text-or-write-to-an-output-file-not-anymore/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

