<?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>User Error</title>
	<atom:link href="http://daniel.streefkerkonline.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://daniel.streefkerkonline.com</link>
	<description>Ramblings of a tinkering SysAdmin</description>
	<lastBuildDate>Mon, 20 May 2013 01:35:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>A quick one-liner to find out a Windows system&#8217;s uptime</title>
		<link>http://daniel.streefkerkonline.com/a-quick-one-liner-to-find-out-a-windows-systems-uptime/</link>
		<comments>http://daniel.streefkerkonline.com/a-quick-one-liner-to-find-out-a-windows-systems-uptime/#comments</comments>
		<pubDate>Mon, 20 May 2013 01:34:56 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Systems Administration]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://daniel.streefkerkonline.com/?p=503</guid>
		<description><![CDATA[Based on the info I found here, this one-liner is a quick way of displaying a Windows system&#8217;s uptime from the command prompt&#8230; net stats srv &#124; find "since" Results in the following: Statistics since 16/05/2013 2:32:48 PM]]></description>
				<content:encoded><![CDATA[<p>Based on the info I found <a href="http://support.microsoft.com/kb/555737" target="_blank">here</a>, this one-liner is a quick way of displaying a Windows system&#8217;s uptime from the command prompt&#8230;</p>
<pre>net stats srv | find "since"</pre>
<p>Results in the following:</p>
<pre>Statistics since 16/05/2013 2:32:48 PM</pre>
]]></content:encoded>
			<wfw:commentRss>http://daniel.streefkerkonline.com/a-quick-one-liner-to-find-out-a-windows-systems-uptime/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ShadowProtect filter driver causing CSV to run in redirected mode on Server 2012</title>
		<link>http://daniel.streefkerkonline.com/shadowprotect-filter-driver-causing-csv-to-run-in-redirected-mode-on-server-2012/</link>
		<comments>http://daniel.streefkerkonline.com/shadowprotect-filter-driver-causing-csv-to-run-in-redirected-mode-on-server-2012/#comments</comments>
		<pubDate>Thu, 15 Nov 2012 01:19:51 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Clustering]]></category>
		<category><![CDATA[Hyper-V]]></category>
		<category><![CDATA[Server 2012]]></category>
		<category><![CDATA[Systems Administration]]></category>

		<guid isPermaLink="false">http://daniel.streefkerkonline.com/?p=497</guid>
		<description><![CDATA[Had an issue on some new Server 2012 Hyper-V clustered hosts. Started seeing the following error in the logs: Cluster Shared Volume 'SERVERNAME' ('') has identified one or more active filter drivers on this device stack that could interfere with &#8230; <a href="http://daniel.streefkerkonline.com/shadowprotect-filter-driver-causing-csv-to-run-in-redirected-mode-on-server-2012/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Had an issue on some new Server 2012 Hyper-V clustered hosts. Started seeing the following error in the logs:</p>
<pre>Cluster Shared Volume 'SERVERNAME' ('') has identified one or more active filter drivers on this device stack that could interfere with CSV operations. I/O access will be redirected to the storage device over the network through another Cluster node. This may result in degraded performance. Please contact the filter driver vendor to verify interoperability with Cluster Shared Volumes. 

Active filter drivers found:
???????????????????????</pre>
<p>Yes, those are random characters in the error message, so it’s difficult to track down the filter driver in question.</p>
<p>This seems to match the same issue in Server 2008 R2 &#8211; <a href="http://support.microsoft.com/kb/2674551" target="_blank">Redirected mode is enabled unexpectedly in a Cluster Shared Volume when you are running a third-party application in a Windows Server 2008 R2-based cluster</a></p>
<p>In the Microsoft KB notes, they state one of the conditions as being:</p>
<ul>
<li><em>The third-party application has a mini-filter driver that uses an altitude value to determine the load order of the mini-filter driver.</em></li>
<li><em><strong>The altitude value contains a decimal point.</strong></em></li>
</ul>
<p>Running <a href="http://msdn.microsoft.com/en-us/library/ff540115(v=vs.85).aspx" target="_blank">fltmc.exe</a> on these hosts shows the following filter drivers loaded:</p>
<p><a href="http://daniel.streefkerkonline.com/uploads/2012/11/image.png"><img style="display: inline; border: 0px;" title="image" src="http://daniel.streefkerkonline.com/uploads/2012/11/image_thumb.png" alt="image" width="640" height="323" border="0" /></a></p>
<p>The filter driver with the decimal point is <em>stcvsm</em>, the “StorageCraft Volume Snapshot Driver” The problem has only been occurring recently, after I installed ShadowProtect.</p>
<p>I’ve had to uninstall ShadowProtect from these servers until it’s officially supported on Server 2012. <a href="http://www.storagecraft.com/blog/shadowprotect-window-server-2012/" target="_blank">According to StorageCraft</a>, that should be 90 days after the official launch date of Server 2012. That means there should be a new version of ShadowProtect around the 3rd of December 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://daniel.streefkerkonline.com/shadowprotect-filter-driver-causing-csv-to-run-in-redirected-mode-on-server-2012/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Capturing standard EXE output in PowerShell</title>
		<link>http://daniel.streefkerkonline.com/capturing-standard-exe-output-in-powershell/</link>
		<comments>http://daniel.streefkerkonline.com/capturing-standard-exe-output-in-powershell/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 00:52:20 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Systems Administration]]></category>

		<guid isPermaLink="false">http://daniel.streefkerkonline.com/?p=492</guid>
		<description><![CDATA[I’m sure there’s a better way of doing this, but here’s how I captured the output of SQL’s bcp.exe in order to email it and the CSV that we were creating automatically on a schedule overnight. I ended up piping &#8230; <a href="http://daniel.streefkerkonline.com/capturing-standard-exe-output-in-powershell/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I’m sure there’s a better way of doing this, but here’s how I captured the output of SQL’s bcp.exe in order to email it and the CSV that we were creating automatically on a schedule overnight.</p>
<p>I ended up piping the executable to a temp file, and then grabbing the contents of that same temp file to populate the email body. Here are the lines in question:</p>
<pre class="brush: ps;">&amp;$exe $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 &gt; c:\temp\out.txt

$bcpOutput = Get-Content c:\temp\out.txt | Out-String
Remove-Item c:\temp\out.txt
</pre>
<p>Here’s the script in its entirety:</p>
<pre class="brush: ps;"># This needs to be set, otherwise Send-MailMessage doesn’t have a server to send through$PSEmailServer ="mailserver.local"
$PSEmailServer ="mailserver.local"

$emailRecipient = "Daniel &lt;daniel@contoso.com&gt;"

# Some date and filename related stuff. This part's not important
$d = Get-Date
$yesterday = $d.AddDays(-1)
$filepath = "C:\Exports\SQL Export\"
$filename = "SQL-DailyExport-{0}.{1}.{2}.csv" -f $yesterday.Day,$yesterday.Month,$yesterday.Year
$fullpath = $filepath + $filename

# Path to the executable
$exe = "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\bcp.exe"

# arguments, as required
$arg1 = "DBName..ViewName"
$arg2 = "out"
$arg3 = $fullpath
$arg4 = "-c"
$arg5 = "-t,"
$arg6 = "-T"

# Run the executable with the arguments, and pipe the STDOut output to a text file
&amp;$exe $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 &gt; c:\temp\out.txt

# An intro line for the body of the email
$bcpOutput = "SQL daily export process information: `r`n"

# Get the contents of the temporary file that we created earlier
$bcpOutput += Get-Content c:\temp\out.txt | Out-String

# Remove the temporary file
Remove-Item c:\temp\out.txt

# Build up our subject line. This part's not important
$subjectText = "SQL export for {0}/{1}/{2}" -f $yesterday.Day,$yesterday.Month,$yesterday.Year

# Append some more information to the end of the body text. Again, not important
$bcpOutput += "`r`nThe output file is attached, and can also be found in \\sql\Exports"

# Send the email with the file attached and the body text as we've built it up
Send-MailMessage -From "SQL Export &lt;Process@sql.server&gt;" -To $emailRecipient -Subject $subjectText -Body $bcpOutput -Attachments $fullpath

</pre>
<p>This results in an email that contains the output from bcp.exe as well as the actual SQL export file attached to the email.</p>
]]></content:encoded>
			<wfw:commentRss>http://daniel.streefkerkonline.com/capturing-standard-exe-output-in-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using bcp.exe from a PowerShell script</title>
		<link>http://daniel.streefkerkonline.com/using-bcp-exe-from-a-powershell-script/</link>
		<comments>http://daniel.streefkerkonline.com/using-bcp-exe-from-a-powershell-script/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 00:39:30 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Systems Administration]]></category>

		<guid isPermaLink="false">http://daniel.streefkerkonline.com/?p=490</guid>
		<description><![CDATA[Recently had to convert a batch file that calls bcp.exe to a more involved PowerShell script. The script exports the contents of a view to CSV format. I originally had some issues getting the command line arguments to work, but &#8230; <a href="http://daniel.streefkerkonline.com/using-bcp-exe-from-a-powershell-script/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently had to convert a batch file that calls bcp.exe to a more involved PowerShell script. The script exports the contents of a view to CSV format. </p>
<p>I originally had some issues getting the command line arguments to work, but here’s how I got it working:</p>
<pre class="brush: ps;">$fullpath = c:\temp\out.csv

$exe = "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\bcp.exe"
$arg1 = "DBName..ViewName"
$arg2 = "out"
$arg3 = $fullpath
$arg4 = "-c"
$arg5 = "-t,"
$arg6 = "-T"

&amp;$exe $arg1 $arg2 $arg3 $arg4 $arg5 $arg6
</pre>
]]></content:encoded>
			<wfw:commentRss>http://daniel.streefkerkonline.com/using-bcp-exe-from-a-powershell-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Outlook/Exchange NDR: &#8220;Delivery has failed to these recipients or groups&#8221; for user with Send-As permissions</title>
		<link>http://daniel.streefkerkonline.com/outlookexchange-ndr-delivery-has-failed-to-these-recipients-or-groups-for-user-with-send-as-permissions/</link>
		<comments>http://daniel.streefkerkonline.com/outlookexchange-ndr-delivery-has-failed-to-these-recipients-or-groups-for-user-with-send-as-permissions/#comments</comments>
		<pubDate>Wed, 10 Oct 2012 06:50:57 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Outlook]]></category>

		<guid isPermaLink="false">http://daniel.streefkerkonline.com/?p=487</guid>
		<description><![CDATA[Had a user today that was receiving an NDR when trying to send as another user. This was strange as this user has always had full mailbox access and send-as permissions to the mailbox in question, so the NDR was &#8230; <a href="http://daniel.streefkerkonline.com/outlookexchange-ndr-delivery-has-failed-to-these-recipients-or-groups-for-user-with-send-as-permissions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Had a user today that was receiving an NDR when trying to send as another user. This was strange as this user has always had full mailbox access and send-as permissions to the mailbox in question, so the NDR was unexpected.</p>
<p>It turned out to be an issue with cached address entries when typing the sender’s address into the “From” field in Outlook. I removed all of the relevant entries and then resolved the sender from the address book, and the email went through without any issues.</p>
<p>One for the memory banks…</p>
]]></content:encoded>
			<wfw:commentRss>http://daniel.streefkerkonline.com/outlookexchange-ndr-delivery-has-failed-to-these-recipients-or-groups-for-user-with-send-as-permissions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tagging and Umbraco</title>
		<link>http://daniel.streefkerkonline.com/tagging-and-umbraco/</link>
		<comments>http://daniel.streefkerkonline.com/tagging-and-umbraco/#comments</comments>
		<pubDate>Fri, 10 Aug 2012 12:02:50 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Umbraco]]></category>

		<guid isPermaLink="false">http://daniel.streefkerkonline.com/?p=485</guid>
		<description><![CDATA[I recently had to implement tagging of content in an Umbraco site that I built. It’s not a very publicised feature of Umbraco, but the functionality is all there in the APIs. There are also a couple of very good &#8230; <a href="http://daniel.streefkerkonline.com/tagging-and-umbraco/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I recently had to implement tagging of content in an Umbraco site that I built. It’s not a very publicised feature of Umbraco, but the functionality is all there in the APIs. There are also a couple of very good extensions that can be installed to make your job easier.</p>
<p>I’ve set up a blank Umbraco 4.7.2 site that I’ll be adding tagging, tag management, and then search/display of tags to.</p>
<h2>Extensions</h2>
<p>The extensions to install are:</p>
<ol>
<li><a href="http://our.umbraco.org/projects/backoffice-extensions/sniper-systems-tags-control" target="_blank">Sniper Systems Tags Control</a> – a jquery-based replacement for the built-in ‘tags’ datatype. This one adds autocomplete, and is easier to use
<li><a href="http://our.umbraco.org/projects/backoffice-extensions/tag-manager" target="_blank">Tag Manager</a> – a custom administration area section for the management of tags. Allows the editor to edit and remove existing tags. Handy for occasions where tags have been typo’d, or when you need to see all content associated with a particular tag.</li>
</ol>
<p>One thing to watch for after installing Tag Manager is that you’ll need to log out/in, and also provide your users access to that section. The “admin” user has access by default.<br /><a href="http://daniel.streefkerkonline.com/uploads/2012/08/2012-08-10_15-09-24.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="2012-08-10_15-09-24" border="0" alt="2012-08-10_15-09-24" src="http://daniel.streefkerkonline.com/uploads/2012/08/2012-08-10_15-09-24_thumb.png" width="356" height="136"></a></p>
<h2>Setting up</h2>
<p>Install both extensions into your site, and then do the following:</p>
<ol>
<li>Create a new DataType that uses the “Sniper Tags” control. I called mine “CWS: Tag” because I’ve installed it on a site that’s built with the <a href="http://umbracocws.codeplex.com/" target="_blank">Creative Website Starter Kit</a>. Ensure that you put something into the “group” field.<br /><a href="http://daniel.streefkerkonline.com/uploads/2012/08/2012-08-10_14-40-26.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="2012-08-10_14-40-26" border="0" alt="2012-08-10_14-40-26" src="http://daniel.streefkerkonline.com/uploads/2012/08/2012-08-10_14-40-26_thumb.png" width="640" height="320"></a>
<li>Add a new property to your Document Type that uses the DataType we just configured. I’m going to be tagging images in this example, so I added it to the “Image” Document Type:<br /><a href="http://daniel.streefkerkonline.com/uploads/2012/08/2012-08-10_14-54-22.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="2012-08-10_14-54-22" border="0" alt="2012-08-10_14-54-22" src="http://daniel.streefkerkonline.com/uploads/2012/08/2012-08-10_14-54-22_thumb.png" width="640" height="349"></a></li>
</ol>
<p>You can now go in and add some tags to your content:<br /><a href="http://daniel.streefkerkonline.com/uploads/2012/08/image.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://daniel.streefkerkonline.com/uploads/2012/08/image_thumb.png" width="629" height="431"></a></p>
<p>Autosuggest for existing tags:<br /><a href="http://daniel.streefkerkonline.com/uploads/2012/08/image1.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://daniel.streefkerkonline.com/uploads/2012/08/image_thumb1.png" width="604" height="443"></a></p>
<h2></h2>
<h2>Using the tag data on the front-end of the website</h2>
<p>Some possible scenarios that you might want to pursue are:</p>
<ul>
<li>Listing the tags on a particular item
<li>Searching by tag name
<li>Displaying related content based on tags</li>
</ul>
<p>These are all quite simple to achieve through the use of the built-in functionality in <a href="http://umbraco.codeplex.com/SourceControl/changeset/view/174ffa96cff7#src%2fumbraco.cms%2fbusinesslogic%2fTags%2fTag.cs" target="_blank">umbraco.cms.businesslogic.Tags</a>. Personally, I find a tool like <a href="http://wiki.sharpdevelop.net/ILSpy.ashx" target="_blank">ILSpy</a> handy when I’m on the go and don’t have access to the Internet. With it, I can view what methods are available to be used.<br /><a href="http://daniel.streefkerkonline.com/uploads/2012/08/image2.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://daniel.streefkerkonline.com/uploads/2012/08/image_thumb2.png" width="442" height="309"></a></p>
<h3></h3>
<h3>Listing all related tags</h3>
<p>Listing all related tags is simple, thanks to <a href="http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/dynamicnode-(and-model)-members-and-properties" target="_blank">DynamicNode</a> and <a href="http://www.asp.net/web-pages/tutorials/basics/2-introduction-to-asp-net-web-programming-using-the-razor-syntax" target="_blank">Razor</a>. Something as simple as this inline macro in your page template will display the related tags, if any exist:</p>
<pre class="brush: csharp;">&lt;umbraco:Macro runat="server" language="cshtml"&gt;
  @if (@Model.HasProperty("tags"))
  {
    &lt;ul&gt;
        @foreach (var tag in @Model.tags)
        {
           &lt;li&gt;@tag&lt;/li&gt;
        }
    &lt;/ul&gt;
  }
&lt;/umbraco:Macro&gt;
</pre>
<p>Here’s how they appear on my test site:</p>
<p><a href="http://daniel.streefkerkonline.com/uploads/2012/08/image3.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://daniel.streefkerkonline.com/uploads/2012/08/image_thumb3.png" width="324" height="228"></a></p>
<h3></h3>
<h3>Searching by tag name</h3>
<p>Searching by tag name is also quite simple. All that’s needed is a new page template that will hold the search results listing. </p>
<p>We’ll take advantage of Umbraco’s functionality that allows for <a href="http://www.nibble.be/?p=42" target="_blank">template switching</a> on the fly. I created a new template with the alias “Tag_Search”. That will allow me to access that particular template from anywhere on the site if I include the alias name in the URL:<br /><a href="http://umbracotest.local/tag_search.aspx?tags=structures">http://umbracotest.local/<strong>tag_search.aspx</strong>?tags=structures</a></p>
<p>The template itself is quite basic. It’s only there to hold a reference to the Razor macro that we’ll create next:</p>
<pre class="brush: xml;">&lt;%@ Master Language="C#" MasterPageFile="~/masterpages/CWS_Master.master" AutoEventWireup="true" %&gt;

&lt;asp:content ContentPlaceHolderId="headerLinksContent" runat="server"&gt;  
&lt;/asp:content&gt;

&lt;asp:content ContentPlaceHolderId="SideBarContent" runat="server"&gt;  
&lt;/asp:content&gt;

&lt;asp:content ContentPlaceHolderId="ChildContent" runat="server"&gt;
    &lt;div id="main" class="content oneCol left clearfix" role="main"&gt;
      &lt;div id="tagsearch"&gt;
        &lt;h2 class="flashHeader"&gt;&lt;strong&gt;Tag Search Results&lt;/strong&gt;&lt;/h2&gt;
        &lt;umbraco:Macro Alias="TagSearch" runat="server"&gt;&lt;/umbraco:Macro&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/asp:content&gt;
</pre>
<p>The macro behind this page needs to do several things:</p>
<ol>
<li>Pick up the value of “tags” out of the querystring
<li>See if there are any content items that match those tags:
<ol>
<li>If there are none, alert the user that there were no matches
<li>If some were found, display them</li>
</ol>
</li>
</ol>
<p>A simple example of this macro is shown below. The key to this is either of the following methods:</p>
<ol>
<li>umbraco.cms.businesslogic.Tags.GetNodesWithTags(string tags)<br />or
<li>umbraco.cms.businesslogic.Tags.GetDocumentsWithTags(string tags)</li>
</ol>
<pre class="brush: csharp;">@inherits umbraco.MacroEngines.DynamicNodeContext
@using System.Text
@using umbraco.MacroEngines
@using umbraco.cms.businesslogic.Tags

@{   
    string searchFor = Request["tags"];
  
    if(string.IsNullOrEmpty(searchFor))
    {
        @* No tags were specified *@ 
        &lt;p&gt;Please specify a tag to search for&lt;/p&gt;
        return;
    }
  
    var matchingNodes = Tag.GetNodesWithTags(searchFor).ToList();

    string tagsText = searchFor.Split(',').Count() &gt; 1 ? "tags" : "tag";
    
    if (matchingNodes.Count &lt; 1)
    {
       @* No results were found for the specified tags *@ 
       &lt;p&gt;No tagged items were found that matched the @tagsText: @searchFor&lt;/p&gt;
       return;        
    }
  
     @* Some results were found for the specified tags *@ 
     &lt;p&gt;&lt;strong&gt;@matchingNodes.Count&lt;/strong&gt; images were found that matched the @tagsText: "@searchFor"&lt;/p&gt;
  
      &lt;ul&gt;
      @foreach (var node in matchingNodes)
      {
        dynamic dn = new DynamicNode(node.Id);
  
        &lt;li&gt;&lt;a href="@dn.Url"&gt;@dn.Name&lt;/a&gt;&lt;/li&gt;
      }
      &lt;/ul&gt;
}
</pre>
<p>The above macro results in this:<a href="http://daniel.streefkerkonline.com/uploads/2012/08/image4.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://daniel.streefkerkonline.com/uploads/2012/08/image_thumb4.png" width="640" height="334"></a></p>
<p>You can also search for multiple tags, delimited by commas:<a href="http://daniel.streefkerkonline.com/uploads/2012/08/image5.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://daniel.streefkerkonline.com/uploads/2012/08/image_thumb5.png" width="640" height="310"></a></p>
<p>Another version could look something like this:<br /><a href="http://daniel.streefkerkonline.com/uploads/2012/08/image6.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://daniel.streefkerkonline.com/uploads/2012/08/image_thumb6.png" width="596" height="480"></a></p>
<p>Once this has been implemented, you can go back and revise the tag listing we created earlier to link to the tag search for each tag:<br /><a href="http://daniel.streefkerkonline.com/uploads/2012/08/image7.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://daniel.streefkerkonline.com/uploads/2012/08/image_thumb7.png" width="490" height="261"></a></p>
<pre class="brush: csharp;">&lt;umbraco:Macro runat="server" language="cshtml"&gt;
  @if (@Model.HasProperty("tags"))
  {
    &lt;div class="tags"&gt;
      &lt;h3 class="flashHeader"&gt;
        &lt;strong&gt;Tags&lt;/strong&gt;
      &lt;/h3&gt;
      &lt;ul&gt;
        @foreach (var tag in @Model.tags)
        {
        &lt;li&gt;&lt;a href="/tag_search.aspx?tags=@tag"&gt;@tag&lt;/a&gt;&lt;/li&gt;
        }
      &lt;/ul&gt;
    &lt;/div&gt; 
  }
&lt;/umbraco:Macro&gt;
</pre>
<h3>Listing related images</h3>
<p>Another use for tags would be to list images that are related to the current one, based on tags. The start of a macro that does this would be:</p>
<pre class="brush: csharp;">@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.MacroEngines
@using umbraco.cms.businesslogic.Tags

@{
  var allTags = string.Join(",",Model.tags.ToArray());
  var matchingNodes = Tag.GetNodesWithTags(allTags);
  
  //logic here to display all images, etc
  @matchingNodes.Count
}
</pre>
<p>This can be used to the following effect:<br /><a href="http://daniel.streefkerkonline.com/uploads/2012/08/image8.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://daniel.streefkerkonline.com/uploads/2012/08/image_thumb8.png" width="503" height="480"></a></p>
<p>As you can see, using tags in Umbraco is very simple. Even a sysadmin like me can use them.</p>
]]></content:encoded>
			<wfw:commentRss>http://daniel.streefkerkonline.com/tagging-and-umbraco/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Batch convert images to B&amp;W with PowerShell and ImageMagick</title>
		<link>http://daniel.streefkerkonline.com/batch-convert-images-to-bw-with-powershell-and-imagemagick/</link>
		<comments>http://daniel.streefkerkonline.com/batch-convert-images-to-bw-with-powershell-and-imagemagick/#comments</comments>
		<pubDate>Thu, 02 Aug 2012 04:27:27 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://daniel.streefkerkonline.com/?p=456</guid>
		<description><![CDATA[I knocked together this PowerShell script today to batch-convert 600+ staff photo images to B&#38;W. You’ll require the following items installed and in your path before this script will work: ImageMagick. I used the normal version, not one of the &#8230; <a href="http://daniel.streefkerkonline.com/batch-convert-images-to-bw-with-powershell-and-imagemagick/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I knocked together this PowerShell script today to batch-convert 600+ staff photo images to B&amp;W. </p>
<p><a href="http://daniel.streefkerkonline.com/uploads/2012/08/2012-08-02-14-07-00_000101.png"><img title="2012-08-02 14-07-00_000101" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="2012-08-02 14-07-00_000101" src="http://daniel.streefkerkonline.com/uploads/2012/08/2012-08-02-14-07-00_000101_thumb.png" width="640" height="398"></a></p>
<p>You’ll require the following items installed <font style="background-color: #ffff00">and in your path</font> before this script will work:</p>
<ol>
<li><a href="http://www.imagemagick.org/script/binary-releases.php#windows" target="_blank">ImageMagick</a>. I used the normal version, not one of the alternate ones.</li>
<li><a href="http://www.sentex.net/~mwandel/jhead/" target="_blank">jhead: exif jpeg header manipulation tool</a>. This requires ImageMagick in order to work.</li>
</ol>
<p>ImageMagick does the actual conversion to B&amp;W. I played with converting to pure grayscale, but it didn’t look good. <a href="http://www.imagemagick.org/Usage/color_mods/#modulate" target="_blank">This method</a> instead strips out all colour information by setting saturation to zero:</p>
<pre>
convert.exe {sourcefile} -modulate 100,0 {destinationfile}
</pre>
<p>An issue I came across then is that ImageMagick <a href="http://www.imagemagick.org/discourse-server/viewtopic.php?f=23&amp;t=20139#p79820" target="_blank">doesn’t update the embedded JPG thumbnail</a>. This issue almost stumped me, but then I came across this great little tool called <a href="http://www.sentex.net/~mwandel/jhead/" target="_blank">jhead</a>. Amongst other things, jhead can regenerate the JPG thumbnail (only if one existed originally):</p>
<pre>
jhead.exe -rgt {filename}
</pre>
<p>Tying it all together is PowerShell:</p>
<pre class="brush: ps;">&lt;#
    .SYNOPSIS
    Generate B&amp;W versions of images 
   
       Daniel Streefkerk
    
    THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE 
    RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
    
    Version 10, 02/08/2012
    
    .DESCRIPTION
    
    This script runs though a folder full of images and creates B&amp;W versions of said images
    
    IMPORTANT NOTE: This script requires ImageMagick and jhead. For more information, see my blog
    
    .PARAMETER RootFolder
    The folder within which to process images

    .PARAMETER Recursive
    Also scan subfolders? This is enabled by default
    
    .EXAMPLE
    Process all images in c:\temp
    .\Generate-BWImages.ps1 -RootFolder c:\temp
    
    #&gt;

Param(
  [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$false,HelpMessage='The folder that contains the photos')]
  [String]
  #[ValidateScript({Test-Path $_ -PathType 'Container'})] 
  $RootFolder,
  [Parameter(Position=1,Mandatory=$false,ValueFromPipeline=$false,HelpMessage='Recurse through all subfolders?')]
  [bool]
  $Recursive=$true
)

cls

# Change these if necessary
$fileExtensions = "*.jpg"
$fileNameSuffix = "_bw" # the text to be appended to the file name to indicate that it has been modified

$files = $null;
$fileCount = 0

# Check if the root folder is a valid folder. If not, try again.
if ((Test-Path $RootFolder -PathType 'Container') -eq $false) {
    Write-Host "'$RootFolder' doesn't seem to be a valid folder. Please try again" -ForegroundColor Red
    break
}

# Get all image files in the folder
if ($Recursive) {
    $files = gci $RootFolder -Filter $fileExtensions -File -Recurse
} else {
    $files = gci $RootFolder -Filter $fileExtensions -File
}
# If there are no image files found, write out a message and quit
if ($files.Count -lt 1) {
    Write-Host "No image files with extension '$fileExtensions' were found in the folder '$RootFolder'" -ForegroundColor Red
    break
}

# Loop through each of the files and process it
foreach ($image in $files) {
    $newFilename = $image.DirectoryName + "\" + $image.BaseName + $fileNameSuffix + $image.Extension
    $imageFullname = $image.FullName

    write-host "Processing image: $imageFullname" -ForegroundColor Green
    &amp; convert.exe $image.FullName -modulate "100,0" $newFilename
    write-host "Updating embedded thumbnail for: $newFilename" -ForegroundColor Green
    &amp; jhead.exe -rgt $newFilename

    $fileCount++
}

Write-Host "$fileCount images processed" -ForegroundColor Yellow
</pre>
]]></content:encoded>
			<wfw:commentRss>http://daniel.streefkerkonline.com/batch-convert-images-to-bw-with-powershell-and-imagemagick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating multiple Exchange 2010 Receive Connectors at once</title>
		<link>http://daniel.streefkerkonline.com/updating-multiple-exchange-2010-receive-connectors-at-once/</link>
		<comments>http://daniel.streefkerkonline.com/updating-multiple-exchange-2010-receive-connectors-at-once/#comments</comments>
		<pubDate>Fri, 27 Jul 2012 05:18:44 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Exchange Server]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Systems Administration]]></category>

		<guid isPermaLink="false">http://daniel.streefkerkonline.com/?p=357</guid>
		<description><![CDATA[Although I haven’t really delved into it properly yet, PowerShell is an awesome tool to have in your toolkit when managing Exchange. When we deployed Exchange 2010, I supplied the sysadmins in our other offices with a list of PowerShell &#8230; <a href="http://daniel.streefkerkonline.com/updating-multiple-exchange-2010-receive-connectors-at-once/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Although I haven’t really delved into it properly yet, PowerShell is an awesome tool to have in your toolkit when managing Exchange. When we deployed Exchange 2010, I supplied the sysadmins in our other offices with a list of PowerShell commands to configure their servers appropriately. This saved a massive amount of time and hassle.</p>
<p>I recently had to bump up the incoming message size limit on our incoming SMTP (from Messagelabs) Receive Connectors to 26MB on five different servers.</p>
<p>Back in the days of Exchange 2003, embarrassingly for me, not that long ago; the same task would have required much mouse clicking and searching for settings. Now, in Exchange 2010, since I’ve followed a naming convention for the connectors across all of the servers, it’s easy to retrieve all of the relevant ones at once:</p>
<pre class="brush: ps;">[PS] C:\&gt;Get-ReceiveConnector |Where-Object  {$_.Identity -like "*Messagelabs*"} | fl identity
<br />Identity : SITE1-MAIL-CAS1\Incoming SMTP from Messagelabs SITE1-MAIL-CAS1
Identity : SITE1-MAIL-CAS2\Incoming SMTP from Messagelabs SITE1-MAIL-CAS2
Identity : SITE2-MAIL\Incoming SMTP from Messagelabs SITE2-MAIL
Identity : SITE3-MAIL\Incoming SMTP from Messagelabs SITE3-MAIL
Identity : SITE4-MAIL\Incoming SMTP from Messagelabs SITE4-MAIL
Identity : SITE5-MAIL\Incoming SMTP from Messagelabs SITE5-MAIL
</pre>
<p>Updating the MaxMessageSize on all of the connectors is then as simple as issuing this one liner:</p>
<pre class="brush: ps;">Get-ReceiveConnector | Where-Object  {$_.Identity -like "*Messagelabs*"} | Set-ReceiveConnector -MaxMessageSize 26mb</pre>
<p>The great thing with many PowerShell commandlets is that you can “get” the objects you’re after, and then pipe the results into the command that makes the changes.</p>
<p>This is just a really simple example, and most experienced Exchange admins would probably laugh at the fact that I’ve documented something this simple – but I just wanted to highlight how easy it is to make “bulk” changes with PowerShell and EMS, the Exchange Management Shell.</p>
<p>Remember that you might want to run commands such as this with the “-WhatIf” switch just to check what’s going to be affected before going ahead:</p>
<pre class="brush: ps;">[PS] C:\&gt;Get-ReceiveConnector |Where-Object  {$_.Identity -like "*Messagelabs*"} |Set-ReceiveConnector -MaxMessageSize 26mb -WhatIf
What if: Configuring Receive connector "SITE1-MAIL-CAS1\Incoming SMTP from Messagelabs SITE1-MAIL-CAS1".
What if: Configuring Receive connector "SITE1-MAIL-CAS2\Incoming SMTP from Messagelabs SITE1-MAIL-CAS2".
What if: Configuring Receive connector "SITE2-MAIL\Incoming SMTP from Messagelabs SITE2-MAIL".
What if: Configuring Receive connector "SITE3-MAIL\Incoming SMTP from Messagelabs SITE3-MAIL".
What if: Configuring Receive connector "SITE4-MAIL\Incoming SMTP from Messagelabs SITE4-MAIL".
What if: Configuring Receive connector "SITE5-MAIL\Incoming SMTP from Messagelabs SITE5-MAIL".
</pre>
]]></content:encoded>
			<wfw:commentRss>http://daniel.streefkerkonline.com/updating-multiple-exchange-2010-receive-connectors-at-once/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
