<feed xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
    <title>Reidar Husmo</title>
    <link rel="self" type="application/xml" href="http://geekswithblogs.net/Norgean/Atom.aspx" />
    <subtitle type="html">SharePoint from the trenches</subtitle>
    <id>http://geekswithblogs.net/Norgean/Default.aspx</id>
    <author>
        <name>Norgean</name>
        <uri>http://geekswithblogs.net/Norgean/Default.aspx</uri>
    </author>
    <generator uri="http://subtextproject.com" version="Subtext Version 0.0.0.0">Subtext</generator>
    <updated>2013-02-10T22:25:06Z</updated>
    <entry>
        <title>Minimal SharePoint 2013 development environment</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2013/02/10/minimal-sharepoint-2013-development-environment.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2013/02/10/minimal-sharepoint-2013-development-environment.aspx</id>
        <published>2013-02-10T22:25:0601:00:00</published>
        <updated>2013-02-10T22:25:06Z</updated>
        <content type="html">&lt;div&gt;What kind of hardware do you need to do SharePoint environment?&lt;/div&gt;&lt;div&gt;Microsoft recommends a minimum of 32Gb for SharePoint Server, less for SharePoint Foundation.&lt;/div&gt;&lt;div&gt;But there are not many laptops in the wild with 32Gb; certainly none that I'd like to have in my lap. (My Dell 4600 does have 32Gb, but I'm a wee fellow at 1.87m, and rather too many kilos.)&lt;/div&gt;&lt;div&gt;This is written on a Samsung 900somethingsomething, a beautiful ultrabook with 8Gb of ram and a 256 SSD.&lt;/div&gt;&lt;div&gt;Probably the nicest thing about this machine is what Apple-users have taken for granted for years now; instant on.&lt;/div&gt;&lt;div&gt;I open the lid, and I can start typing almost immediately (I've disabled "require password when resuming).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, given that this is the PC I like to use when I'm pretending to watch "When Harry met Sally" or "Eurovision Song Contest," wouldn't it be nice if this machine can run SharePoint?&lt;/div&gt;&lt;div&gt;Purchase Win8Pro, enable hyper-v, and...&lt;/div&gt;&lt;div&gt;Joy!&lt;/div&gt;&lt;div&gt;I chose to install SP with the minimum of services. No search, workflow, excel services or similar for me. If I want to play with those things, I'll do it at work.&lt;/div&gt;&lt;div&gt;I gave the vm 5550Mb, which win8 claimed was the maximum.&lt;/div&gt;&lt;div&gt;With VS2012 and IE with a couple of sites open, I'm still juuust south of 4Gb.&lt;/div&gt;&lt;div&gt;Which isn't bad.&lt;/div&gt;&lt;div&gt;I've also configured my Samsung for silent running (i.e. max battery lifetime, and slow down the cpu so that the fan doesn't need to spin). So it isn't fast. But the things I want to play with, team sites, apps, ecm, do work.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;img src="http://geekswithblogs.net/Norgean/aggbug/152067.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/152067.aspx</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/152067.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/152067.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Use "Add as link" to unit test SharePoint</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2013/02/06/use-add-as-link-to-unit-test-sharepoint.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2013/02/06/use-add-as-link-to-unit-test-sharepoint.aspx</id>
        <published>2013-02-06T21:25:1901:00:00</published>
        <updated>2013-02-06T21:28:43Z</updated>
        <content type="html">&lt;p&gt;Unit testing SharePoint is difficult for a number of reasons.&lt;/p&gt;&lt;p&gt;One of the better known ones is perhaps that of the GAC; the .net loader ("Fusion") will use assemblies from the GAC even if you specify the full path to the newly-built-but-not-yet-tested-dll.&lt;/p&gt;&lt;p&gt;If you are unaware of this, it can be an extremely frustrating experience - or so I've been told... ("...but... how can that code possibly still be wrong?! I've commented it all out!")&lt;/p&gt;&lt;p&gt;In the past I've attempted daft things like renaming the dll to "something that has never been gacced" (ie. &amp;lt;whatever&amp;gt;2.dll), and adding that dll as a reference in my test project. (in case you want to know: No, it doesn't work)&lt;/p&gt;&lt;p&gt;Today I came across a better way in a presentation by Bill Ayers. And by better, I mean it actually works.&lt;/p&gt;&lt;p&gt;Briefly: In the test project, "add as a link" the class you want to test. ("Add existing item...", browse to the cs file in the SharePoint project, select it, and add as link - it's a drop-down button.)&lt;/p&gt;&lt;p&gt;Of course, the linked cs-file is now (also) a part of the test-project, so if the file makes calls to code in other files, they have to be linked to, too. Etc.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;img src="http://geekswithblogs.net/Norgean/aggbug/152044.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/152044.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/152044.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/152044.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Installing SharePoint 2013 preview on a standalone, workgroup server</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2012/07/21/installing-sharepoint-2013-preview-on-a-standalone-workgroup-server.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2012/07/21/installing-sharepoint-2013-preview-on-a-standalone-workgroup-server.aspx</id>
        <published>2012-07-21T21:44:0002:00:00</published>
        <updated>2012-11-13T09:03:28Z</updated>
        <content type="html">&lt;p&gt;If you try to install SP2013 on a standalone (i.e. not joined to a domain controller), you will eventually get an error.&lt;/p&gt;  &lt;p&gt;"Service running under Network Service account in workgroup environment is not supported."&lt;/p&gt;  &lt;p&gt;To avoid this error, create the configuration database after the main setup &lt;em&gt;before&lt;/em&gt; you run the “Configuring SharePoint Products” wizard. &lt;/p&gt;  &lt;p&gt;Open Powershell, add the usual snapin if necessary (depends on what you do when I say “Open Powershell”!), ignore the warning about missing implementingType for education.institution.dll, and then do a&lt;/p&gt;  &lt;p&gt;New-SPConfigurationDatabase&lt;/p&gt;  &lt;p&gt;That’s it! Now you can run the Config wizard, and everything should be ok. Well, things were ok on the three servers I’ve tried it on so far. &lt;/p&gt;&lt;p&gt;Note: Do not do this if you ever intend to do any workflow stuff. Things will not work.&lt;/p&gt;&lt;img src="http://geekswithblogs.net/Norgean/aggbug/150273.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/150273.aspx</wfw:comment>
        <slash:comments>5</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/150273.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/150273.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Html 5 clock, part ii - CSS marker classes and getElementsByClassName</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2012/07/05/css-marker-classes.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2012/07/05/css-marker-classes.aspx</id>
        <published>2012-07-05T10:11:5902:00:00</published>
        <updated>2012-07-05T20:56:30Z</updated>
        <content type="html">&lt;p&gt;The clock I made in part i displays the time in "long" - "It's a quarter to ten" (but in Norwegian).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/norgean/Windows-Live-Writer/Html-5-clock-part-ii---CSS-marker-classe_8E6B/QuarterToTen_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="QuarterToTen" border="0" alt="QuarterToTen" src="http://gwb.blob.core.windows.net/norgean/Windows-Live-Writer/Html-5-clock-part-ii---CSS-marker-classe_8E6B/QuarterToTen_thumb.png" width="228" height="131" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To save space, some letters are shared, "sevenineight" is four letters shorter than "seven nine eight".&lt;/p&gt;  &lt;p&gt;We only want to highlight the "correct" parts of this, for example "&lt;b&gt;seven&lt;/b&gt;ineight".&lt;/p&gt;  &lt;p&gt;When I started programming the clock, each letter had its own unique ID, and my script would "get" each element individually, and highlight / hide each element according to some obscure logic. &lt;/p&gt;  &lt;p&gt;I quickly realized, despite being in a post surgery haze, …this is a stupid way to do it.&lt;/p&gt;  &lt;p&gt;And, to paraphrase NPH, if you find yourself doing something stupid, stop, and be awesome instead.&lt;/p&gt;  &lt;p&gt;We want an easy way to get all the items we want to highlight.&lt;/p&gt;  &lt;p&gt;Perhaps we can use the new getElementsByClassName function?&lt;/p&gt;  &lt;p&gt;Try to mark each element with a classname or two.&lt;/p&gt;  &lt;p&gt;So in "sevenineight": 's' is marked as 'h7', and the first 'n' is marked with &lt;em&gt;both&lt;/em&gt; 'h7' and 'h9' (h for hour).&lt;/p&gt;  &lt;p&gt;&lt;font face="Lucida Console"&gt;&amp;lt;div class='&lt;font color="#800080"&gt;h7 h9&lt;/font&gt;'&amp;gt;N&amp;lt;/div&amp;gt;&amp;lt;div class='&lt;font color="#800080"&gt;h9&lt;/font&gt;'&amp;gt;I&amp;lt;/div&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;getElementsByClassName('h9') will return the four letters of "nine". &lt;/p&gt;  &lt;p&gt;Notice that these classes are &lt;em&gt;not&lt;/em&gt; backed by any CSS, they only appear directly in html (and are used in javascript).&lt;/p&gt;  &lt;p&gt;I have not seen classes used this way elsewhere, and have chosen to call them "marker classes" - similar to marker interfaces - until somebody comes up with a better name.&lt;/p&gt;&lt;img src="http://geekswithblogs.net/Norgean/aggbug/150139.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/150139.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/150139.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/150139.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Html 5 &amp;ndash; new size units</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2012/07/04/html-5-ndash-new-size-units.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2012/07/04/html-5-ndash-new-size-units.aspx</id>
        <published>2012-07-04T22:50:5502:00:00</published>
        <updated>2012-07-04T22:50:55Z</updated>
        <content type="html">&lt;p&gt;There are some new size units with CSS 3, which allows you to resize elements relative to the viewport size. They are vw, vh, vmin (that’s vm in IE), and perhaps vmax. (Viewport width, height, smaller of the two, larger of the two.)&lt;/p&gt;  &lt;p&gt;8vw is 8% of the viewport width – or 205 pixels on my 2560 screen.&lt;/p&gt;  &lt;p&gt;I created a tiny demo clock which sizes the elements so that it uses the whole screen. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://husmo.sharepoint.com/klokke2.aspx"&gt;Clock&lt;/a&gt; – in Norwegian, but it’s the source that is interesting…&lt;/p&gt;  &lt;p&gt;Bug: Resize does not work.&lt;/p&gt;  &lt;p&gt;Tested for IE 9 &amp;amp; 10 and Chrome. Firefox and Safari: does not work.&lt;/p&gt;&lt;img src="http://geekswithblogs.net/Norgean/aggbug/150136.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/150136.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/150136.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/150136.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Creating large SharePoint structures from Powershell and xml, part ii</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2012/06/30/creating-large-sharepoint-structures-from-powershell-and-xml-part-ii.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2012/06/30/creating-large-sharepoint-structures-from-powershell-and-xml-part-ii.aspx</id>
        <published>2012-06-30T19:21:5002:00:00</published>
        <updated>2012-06-30T19:27:00Z</updated>
        <summary type="html">In this second part, we show how we can build an xml structure from information we get from SharePoint. This xml can later be edited, and used as input to the SharePoint creator from part i.</summary>
        <content type="html">In this second part, we show how we can build an xml structure from information we get from SharePoint. This xml can later be edited, and used as input to the SharePoint creator from part i.&lt;img src="http://geekswithblogs.net/Norgean/aggbug/150091.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/150091.aspx</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/150091.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/150091.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Creating large SharePoint structures from Powershell and xml</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2012/06/30/creating-large-sharepoint-structures-from-powershell-and-xml.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2012/06/30/creating-large-sharepoint-structures-from-powershell-and-xml.aspx</id>
        <published>2012-06-30T18:25:0802:00:00</published>
        <updated>2012-06-30T19:29:15Z</updated>
        <summary type="html">In this two-part series, we show how we can (easily) create large SharePoint structures using Powershell and xml - and hashtables(!?)</summary>
        <content type="html">In this two-part series, we show how we can (easily) create large SharePoint structures using Powershell and xml - and hashtables(!?)&lt;img src="http://geekswithblogs.net/Norgean/aggbug/150090.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/150090.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/150090.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/150090.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Creating SharePoint sites from xml using Powershell</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2012/04/12/creating-sharepoint-sites-from-xml-using-powershell.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2012/04/12/creating-sharepoint-sites-from-xml-using-powershell.aspx</id>
        <published>2012-04-12T14:53:4402:00:00</published>
        <updated>2012-04-12T14:53:44Z</updated>
        <content type="html">&lt;p&gt;&lt;font face="Arial"&gt;It is frequently useful to create / delete web applications in a development environment.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Arial"&gt;If you need to create a structure, this can quickly become tedious.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Arial"&gt;Enter Powershell, xml and recursive functions.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Arial"&gt;Create the structure in xml. Something like:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#333333" size="2" face="Lucida Console"&gt;&amp;lt;Sites&amp;gt;     &lt;br /&gt;    &amp;lt;Site Name="Test 1" Url="Test1" /&amp;gt;      &lt;br /&gt;    &amp;lt;Site Name="Test 2" Url="Test2" &amp;gt;      &lt;br /&gt;        &amp;lt;Site Name="Test 2 1" Url="Test21" &amp;gt;      &lt;br /&gt;            &amp;lt;Site Name="Test 2 1 1" Url="Test211" /&amp;gt;      &lt;br /&gt;            &amp;lt;Site Name="Test 2 1 2" Url="Test212" /&amp;gt;      &lt;br /&gt;        &amp;lt;/Site&amp;gt;      &lt;br /&gt;    &amp;lt;/Site&amp;gt;      &lt;br /&gt;    &amp;lt;Site Name="Test 3" Url="Test3" &amp;gt;      &lt;br /&gt;        &amp;lt;Site Name="Test 3 1" Url="Test31" /&amp;gt;      &lt;br /&gt;        &amp;lt;Site Name="Test 3 2" Url="Test32" /&amp;gt;      &lt;br /&gt;        &amp;lt;Site Name="Test 3 3" Url="Test33" &amp;gt;      &lt;br /&gt;            &amp;lt;Site Name="Test 3 3 1" Url="Test331" /&amp;gt;      &lt;br /&gt;            &amp;lt;Site Name="Test 3 3 2" Url="Test332" /&amp;gt;      &lt;br /&gt;        &amp;lt;/Site&amp;gt;      &lt;br /&gt;        &amp;lt;Site Name="Test 3 4" Url="Test34" /&amp;gt;      &lt;br /&gt;    &amp;lt;/Site&amp;gt;      &lt;br /&gt;&amp;lt;/Sites&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Arial"&gt;Read this structure in Powershell, and recursively create the sites. Oh, and have cool progress dialogs, too.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#333333" size="2" face="Lucida Console"&gt;$snap = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" }     &lt;br /&gt;if ($snap -eq $null)      &lt;br /&gt;{      &lt;br /&gt;    Add-PSSnapin "Microsoft.SharePoint.Powershell"      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#333333" size="2" face="Lucida Console"&gt;function &lt;font color="#9b00d3"&gt;CreateSites&lt;/font&gt;($baseUrl, $sites, [int]$progressid)      &lt;br /&gt;{      &lt;br /&gt;    $sitecount = $sites.ChildNodes.Count      &lt;br /&gt;    $counter = 0      &lt;br /&gt;    &lt;font color="#9b00d3"&gt;foreach ($site in $sites.Site)&lt;/font&gt;      &lt;br /&gt;    {      &lt;br /&gt;        Write-Progress -ID $progressid -Activity "Creating sites" -status "Creating $($site.Name)" -percentComplete ($counter / $sitecount*100)      &lt;br /&gt;        $counter = $counter + 1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#333333"&gt;&lt;font size="2" face="Lucida Console"&gt;        Write-Host "Creating $($site.Name) $($baseUrl)/$($site.Url)"       &lt;br /&gt;        &lt;font color="#9b00d3"&gt;New-SPWeb -Url "$($baseUrl)/$($site.Url)" -AddToQuickLaunch:$false -AddToTopNav:$false -Confirm:$false -Name "$($site.Name)" -Template "STS#0" -UseParentTopNav:$true&lt;/font&gt;        &lt;br /&gt;        if ($site.ChildNodes.Count -gt 0)        &lt;br /&gt;        {        &lt;br /&gt;            &lt;font color="#9b00d3"&gt;CreateSites "$($baseUrl)/$($site.Url)" $site ($progressid +1)         &lt;br /&gt;&lt;/font&gt;        }        &lt;br /&gt;        Write-Progress -ID $progressid -Activity "Creating sites" -status "Creating $($site.Name)" -Completed        &lt;br /&gt;    }        &lt;br /&gt;}&lt;/font&gt;      &lt;br /&gt;&lt;/font&gt;&lt;font color="#333333" size="2" face="Lucida Console"&gt;# read an xml file     &lt;br /&gt;&lt;font color="#9b00d3"&gt;$xml = [xml](Get-Content "C:\Projects\Powershell\sites.xml")       &lt;br /&gt;&lt;/font&gt;$xml.PreserveWhitespace = $false&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#9b00d3" size="2" face="Lucida Console"&gt;CreateSites "&lt;/font&gt;&lt;a href="http://$("&gt;&lt;font color="#9b00d3" size="2" face="Lucida Console"&gt;http://$(&lt;/font&gt;&lt;/a&gt;&lt;font color="#9b00d3" size="2" face="Lucida Console"&gt;$env:computername)" $xml.Sites 1     &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Arial"&gt;Easy!&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Arial"&gt;Sensible real life implementations will also include templateid in the xml, will check for existence of a site before creating it, etc.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://geekswithblogs.net/Norgean/aggbug/149295.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/149295.aspx</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/149295.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/149295.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Powershell progress dialogs</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2012/04/11/powershellprogressdialogs.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2012/04/11/powershellprogressdialogs.aspx</id>
        <published>2012-04-11T13:21:5502:00:00</published>
        <updated>2012-04-11T14:35:11Z</updated>
        <content type="html">&lt;p style="margin: 0in; font-family: calibri; font-size: 11pt" lang="nb-NO"&gt;Creating nested progress dialogs in Powershell is easy.&lt;/p&gt;  &lt;p style="margin: 0in; font-family: calibri; font-size: 11pt" lang="nb-NO"&gt;Let the code speak for itself:&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;for ($i = 1; $i -le 2; $i++)&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;{ &lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;    Write-Progress -ID 1 -Activity "Outer loop" -Status "Tick $i" -percentComplete ($i / 2*100)&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;    for ($j = 1; $j -le 3; $j++)&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;    { &lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;        Write-Progress -ID 2 -Activity "Mid loop" -Status "Tick $j" -percentComplete ($j / 3*100)&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;        for ($k = 1; $k -le 3; $k++)&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;        { &lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;            Write-Progress -ID 3 -Activity "Inner loop" -Status "Tick $k" -percentComplete ($k / 3*100)&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;            Sleep(1)&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;        }&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;    }&lt;/p&gt;  &lt;p style="margin: 0in; font-family: &amp;quot;Lucida Console&amp;quot;; font-size: 9pt" lang="nb-NO"&gt;}&lt;/p&gt;  &lt;p style="margin: 0in; font-family: calibri; font-size: 11pt" lang="nb-NO"&gt;I.e. some text that explains what we're doing (Activity and Status), and ID numbers.&lt;/p&gt;  &lt;p style="margin: 0in; font-family: calibri; font-size: 11pt" lang="nb-NO"&gt;Easy.&lt;/p&gt;  &lt;p style="margin: 0in; font-family: calibri; font-size: 11pt" lang="nb-NO"&gt;Powershell ISE:&lt;/p&gt;  &lt;p style="margin: 0in; font-family: calibri; font-size: 11pt" lang="nb-NO"&gt;&lt;a href="http://gwb.blob.core.windows.net/norgean/Windows-Live-Writer/Powershell-progress-dialogs_BCB4/ProgressDialog_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ProgressDialog" border="0" alt="ProgressDialog" src="http://gwb.blob.core.windows.net/norgean/Windows-Live-Writer/Powershell-progress-dialogs_BCB4/ProgressDialog_thumb.png" width="356" height="250" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p style="margin: 0in; font-family: calibri; font-size: 11pt" lang="nb-NO"&gt;And in the console window:&lt;/p&gt;  &lt;p style="margin: 0in; font-family: calibri; font-size: 11pt" lang="nb-NO"&gt;&lt;a href="http://gwb.blob.core.windows.net/norgean/Windows-Live-Writer/Powershell-progress-dialogs_BCB4/ProgressShell_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ProgressShell" border="0" alt="ProgressShell" src="http://gwb.blob.core.windows.net/norgean/Windows-Live-Writer/Powershell-progress-dialogs_BCB4/ProgressShell_thumb.png" width="517" height="102" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://geekswithblogs.net/Norgean/aggbug/149284.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/149284.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/149284.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/149284.aspx</trackback:ping>
    </entry>
    <entry>
        <title>CAML queries for humans</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/Norgean/archive/2012/03/28/camlqueries.aspx" />
        <id>http://geekswithblogs.net/Norgean/archive/2012/03/28/camlqueries.aspx</id>
        <published>2012-03-28T10:40:1602:00:00</published>
        <updated>2012-03-28T10:40:16Z</updated>
        <summary type="html">In which I show how you can write CAML queries that are understandable, and show how you can query from Powershell.</summary>
        <content type="html">&lt;p style="margin:0in;font-family:Calibri;font-size:11.0pt" lang="nb-NO"&gt;I've
recently had to help a couple of splinq-challenged colleagues with some caml
queries.&lt;/p&gt;

&lt;p style="margin:0in;font-family:Calibri;font-size:11.0pt" lang="nb-NO"&gt;Here are
some of my favourite ways to make caml edible.&lt;/p&gt;

&lt;ul type="disc" style="margin-left:.375in;direction:ltr;unicode-bidi:embed;&amp;#xD;&amp;#xA; margin-top:0in;margin-bottom:0in"&gt;
 &lt;li style="margin-top:0;margin-bottom:0;vertical-align:middle" lang="nb-NO"&gt;&lt;span style="font-family:Calibri;font-size:11.0pt"&gt;Use '! &lt;br /&gt;
          Too many developers seem ignorant of the fact that xml works just as
     well with single apostrophes as with double. This is, of course, also true
     for other things, like html. &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ul type="disc" style="margin-left:.375in;direction:ltr;unicode-bidi:embed;&amp;#xD;&amp;#xA; margin-top:0in;margin-bottom:0in"&gt;
 &lt;li style="margin-top:0;margin-bottom:0;vertical-align:middle" lang="nb-NO"&gt;&lt;span style="font-family:Calibri;font-size:11.0pt"&gt;Use @ and multiline&lt;/span&gt;&lt;/li&gt;
 &lt;li style="margin-top:0;margin-bottom:0;vertical-align:middle" lang="nb-NO"&gt;&lt;span style="font-family:Calibri;font-size:11.0pt"&gt;Use string.Format&lt;/span&gt;&lt;/li&gt;
 &lt;li style="margin-top:0;margin-bottom:0;vertical-align:middle" lang="nb-NO"&gt;&lt;span style="font-family:Calibri;font-size:11.0pt"&gt;Validate the query using a
     simple webpart or, much better, powershell&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ul type="disc" style="margin-left:.375in;direction:ltr;unicode-bidi:embed;&amp;#xD;&amp;#xA; margin-top:0in;margin-bottom:0in"&gt;
 &lt;li style="margin-top:0;margin-bottom:0;vertical-align:middle" lang="nb-NO"&gt;&lt;span style="font-family:Calibri;font-size:11.0pt"&gt;Don't use third-party clever
     stuff&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p style="margin:0in;margin-left:.375in;font-family:Calibri;font-size:11.0pt"&gt;&lt;span lang="nb-NO"&gt;I'm not sarcastic when I say "clever," I'm really
impressed with what some people, like John Holliday, have done. But I have two
major problems. You include a dependency to a dll which is outside your
control, which can lead to all kinds of interesting deployment and upgrade
problems. But more importantly, these additions seldom cover 100% of the
functionality, and you may therefore think that something is impossible just
because the addition &lt;/span&gt;&lt;span lang="en-GB"&gt;doesn't&lt;/span&gt;&lt;span lang="nb-NO"&gt;
support it.&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in;font-family:Calibri;font-size:11.0pt" lang="nb-NO"&gt;So,
examples.&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;var query
= new SPQuery();&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;query.Query
= "&amp;lt;Where&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=\"Severity\"
/&amp;gt;&amp;lt;Value
Type=\"Choice\"&amp;gt;Error&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/Where&amp;gt;";&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin:0in;font-family:Calibri;font-size:11.0pt" lang="nb-NO"&gt;becomes&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;query.Query
= @"&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt; &amp;lt;Where&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;    &amp;lt;Eq&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;      &amp;lt;FieldRef
Name='Severity' /&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;      &amp;lt;Value
Type='Choice'&amp;gt;Error&amp;lt;/Value&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;    &amp;lt;/Eq&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;  &amp;lt;/Where&amp;gt;";&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin:0in;font-family:Calibri;font-size:11.0pt" lang="nb-NO"&gt;Which,
IMHO, is more readable.&lt;/p&gt;

&lt;p style="margin:0in;font-family:Calibri;font-size:11.0pt" lang="nb-NO"&gt;Another
example using string.Format:&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="Calibri" style="font-size: 11pt; "&gt;            &lt;/font&gt;&lt;font face="'Courier New'" size="1" color="#006400"&gt;query.Query =
string.Format(@"&amp;lt;Where&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="1" color="#006400"&gt;                                           
&amp;lt;Eq&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="1" color="#006400"&gt;                                               
&amp;lt;FieldRef Name='Title'/&amp;gt;&amp;lt;Value Type='Text'&amp;gt;{0}&amp;lt;/Value&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="1" color="#006400"&gt;                                           
&amp;lt;/Eq&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="1" color="#006400"&gt;                                       
&amp;lt;/Where&amp;gt;", filename); // GAH! sorry about tabification (blog editor)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin:0in;font-family:Calibri;font-size:11.0pt" lang="nb-NO"&gt;And how
do you test it in PowerShell?&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;$filename
= "test"&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;$query =
New-Object Microsoft.SharePoint.SPQuery&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;$query.Query
= @"&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;&amp;lt;Where&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;    &amp;lt;Eq&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;            &amp;lt;FieldRef Name='Title'/&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;            &amp;lt;Value
Type='Text'&amp;gt;$($filename)&amp;lt;/Value&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;    &amp;lt;/Eq&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;&amp;lt;/Where&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;"@&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;# See?
Powershell does multiline strings, too!&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;# yes,
Powershell has string.Format - but in Powershell I prefer using the built-in
mechanism&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;$items =
$list.GetItems($query)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;foreach
($item in $items)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;    Write-Host -NoNewline $item.DisplayName&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; " lang="nb-NO"&gt;&lt;font face="'Courier New'" size="2" color="#006400"&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin:0in;font-family:Calibri;font-size:11.0pt" lang="nb-NO"&gt; &lt;/p&gt;

&lt;p style="margin:0in;font-family:Calibri;font-size:11.0pt" lang="nb-NO"&gt;Beautiful,
just beautiful. Well, the PowerShell bit, not the CAML bit. Splinq is,
obviously, much prettier.&lt;/p&gt;&lt;img src="http://geekswithblogs.net/Norgean/aggbug/149124.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/Norgean/comments/149124.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/Norgean/comments/commentRss/149124.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/Norgean/services/trackbacks/149124.aspx</trackback:ping>
    </entry>
</feed>