Free ebook: Programming Windows 8 Apps with HTML, CSS, and JavaScript

For those of you looks at the new Windows 8 platform and how to use items like the WinJS, commanding UI, animations and sensors, it’s a really nice run down of everything you would want for building out a basic and elegant Windows 8 app on a mobile platform.

I’ve skimmed the chapters and am now diligently working my way through the exercises…

http://blogs.msdn.com/b/microsoft_press/archive/2012/08/20/free-ebook-programming-windows-8-apps-with-html-css-and-javascript-second-preview.aspx

Microsoft Virtual Academy – Developing in HTML5 with JavaScript and CSS3 Jump Start, Free Certification for Exam 70-480

It’s been a while since I’ve written about this great little resource from Microsoft.  I originally wrote about their launch here.  Since then they’ve had some great training courses on SharePoint Online and Office 365.  Now they’re at it again with some great coursework from Jeremy Foster and Michael Palermo and I’m working my way through their excellent course on HTML5, JavaScript and CSS3.

Here is the course: https://www.microsoftvirtualacademy.com/tracks/developing-html5-apps-jump-start

This course provides an accelerated introduction to HTML5, CSS3, and JavaScript and helps students gain basic HTML5/CSS3/JavaScript programming skills. This course is an entry point into both the Web application and Windows Store apps training paths and helps prepare learners for Microsoft exam 70-480. The course focuses on using HTML5/CSS3/JavaScript to implement programming logic, define and use variables, perform looping and branching, develop user interfaces, capture and validate user input, store data, and create well-structured applications. This course uses Visual Studio 2012, running on Windows 8.

Audience Profile | The course is intended for developers who have at least six months of professional experience and who are interested in developing applications using HTML5 with JavaScript and CSS3 (either Windows Store apps or IE10 apps for the Web). While the students may have little or no HTML5 coding experience, they should have some experience with HTML4.
The popular “Jump Start” virtual classroom experience leverages two experts and an engaging team-teaching approach. We’re excited to introduce Jeremy Foster and Michael Palermo – two seasoned Microsoft Technical Evangelists with real world experience developing applications using a wide array of platforms and languages. Both Jeremy and Michael share a passion for creating powerful solutions leveraging HTML, CSS and JavaScript and are excited to dive into these topics together.

FREE EXAM VOUCHER FOR 70-480! | Register now to take Exam 70-480 Programming in HTML5 with JavaScript and CSS3 for FREE! Just use this voucher code when scheduling your exam: HTMLJMP (voucher code available through 3/31/2013 or while supplies last.)

So a great opportunity to get some more training under the belt during the holidays and a free exam voucher!  Awesome little gift from Microsoft.

PowerShell 3.0 (KB2506143) and SharePoint 2010, Not There Yet

So a bit of a rant, but as it turns out installing the Windows Management Framework 3.0 (KB2506143) on a SharePoint 2010 server is not such a good idea.

After installing the Windows Management Framework 3.0 on a SharePoint 2010 Server I can’t use the "SharePoint 2010 Management Shell" anymore.  SharePoint uses .NET 3.5 and PowerShell 3.0 uses .NET 4, so when I try to open the SharePoint management console and run a SharePoint cmdlet I get some fun errors that Microsoft SharePoint is not supported by Version 4.0

A PlatformNotSupportedException occured while trying to acquire the local farm: System.PlatformNotSupportedException: Microsoft SharePoint is not supported with version 4.0.30319.586 of the Microsoft .Net Runtime. at Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_Farm() at Microsoft.SharePoint.Administration.SPFarm.FindLocal(SPFarm& farm, Boolean& isJoined)

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

So thanks for the lack of warning… but the fix is easy enough:

  1. Open the Installed Updates on the server
  2. search for KB2506143
  3. Uninstall
  4. Reboot
  5. Open PowerShell and type “(Get-Host).version”, you’ll see it is now running in 2.0 mode again.

You would think that during the install process of the WMF 3.0 it might check for SharePoint components and at least give a warning, but as the PowerShell team says here: http://connect.microsoft.com/PowerShell/feedback/details/746908/powershell-3-0-and-sharepoint-2010

Posted by Microsoft on 6/7/2012 at 12:34 PM

This is not an issue with Windows PowerShell. This is an issue with SharePoint 2010. The SharePoint team is aware of this compatibility issue and plans to address it in an upcoming release or service pack.

Truncate all Items in an SPList in SharePoint Using ProcessBatchData Command

This came up recently in regards to some of our test systems, where we were testing one of our systems that used large amounts of rows in an SPList.  As we were adding items through a scripted process “someone” (ok, it was me…) fat-fingered one of the scripts and next thing I knew we had roughly 30K rows from the wrong test bank sitting in our testing system.  Rather than just delete the SPList and start over I thought that there must be a better way to just truncate the table. 

All I could find were scripts that went through the item collection and called the .Delete() function on each item.  This delete process takes roughly a quarter of a second per item, with 30K items to delete we were looking at 2 hours to iterate through.  Not too bad, but not great when you’re sitting on a deadline.  So with a little investigation I found the ProcessBatchData function, which allows us to process multiple requests to the server per transaction.  Using this method we can pass XML formatted Collaborative Application Markup Language (CAML) that contains the commands, which consists of a Batch element and any number of subordinate Method elements that each specify a SharePoint Foundation remote procedure call (RPC) method.

It worked so well that I wrote it up as my very first Gallery submission to MSDN.

Here’s the link, if you like it, rate me a 5 Smile

http://gallery.technet.microsoft.com/sharepoint/Truncate-all-Items-in-an-2841c740

And for posterity, here is the original text of the submission… 

Introduction

This script will demonstrate how to delete Items from a Microsoft SharePoint list using Windows PowerShell and Microsoft SharePoint PowerShell snapin utilizing the ProcessBatchData command and building an XML command structure.

Scenario

Occasionally I have received requests to delete large amounts of data consisting of over 30,000 items. Previous scripts I used would iterate through the Items in the SPList and delete each item on a per item basis. However this was taking considerable time, using this method we can quickly delete items in batches of 100 even 1000 and remove these items.

Script

This script leverages the capability of Windows PowerShell and the ProcessBatchData to pass an XML request to the parent web to delete the list items in a batch.

You can use this script by following steps:

  1. Download the script and copy it to a Microsoft SharePoint 2010 Server which will be used for testing.
  2. Run the .\Truncate-SPList command inside SharePoint Management Powershell.
  3. Enter the URL and Name of the list ( or pass in parameters for -SiteURL and -ListName
  4. Confirm that you want to remove all items from the list ( ‘y’ )

Copy Code

 

## Truncate-SPList 
## Remove all items in a SharePoint List, batched up for processing in large chunks for a quick delete process 
## NOTE: This is not a true "Truncate", as SharePoint will never reuse an Item ID so seed is not reset 
## 
## Usage: Truncate-SPList -SiteUrl http://Server/Site  -ListName List 
## 
## Author:  
##    ieDaddy  
##    web: http://iedaddy.com 
##    twitter: @ieDaddy 
##              
##          
 
Param( 
    [Parameter(Mandatory=$true)] [String] $SiteUrl, 
    [Parameter(Mandatory=$true)] [String] $ListName 
    ) 
     
Function TruncateSPList  
{ 
    ## Parameter validation 
    Try  
    {  
        ## Use Get-SPWeb get the website we want, on error don't go further 
        $spWeb = Get-SPWeb -Identity $SiteURL -ErrorAction Stop -Verbose:$false  
    }  
    Catch   
    {  
        #If Get-SPSite failed for any reason, this function will be terminated.  
        Write-Host $Error[0] 
        return $null  
    }  
    ## Get the specified list, $spList is a instance of Microsoft.SharePoint.SPList class  
    $spList = $spWeb.Lists[$ListName] 
 
     
    if ($spList -ne $null)  
    { 
        ## This looping goes through one by one, but maybe a better way? 
        #ForEach ($item in $spList.items) 
        #{ 
        #    $ItemToDelete=$splist.GetItemById($item.ID) 
        #    write-host 'Deleting : ' $ItemToDelete.ID 
        #    $ItemToDelete.Delete() 
        #} 
         
        ## Set up a do..until loop so we can batch the removals 100 records at a time     
        do  
        { 
            ## Set up our Items Collection for Batch Processing 
            $spQuery = new-object Microsoft.SharePoint.SPQuery  
            $spQuery.RowLimit = 100 
            $spQuery.Query = "" 
            ## Get collection of items to be deleted for the batch delete 
            $spListItemCollection = $spList.GetItems($spQuery) 
            $batchRemove = '<?xml version="1.0" encoding="UTF-8"?><Batch>';    
            ## The command is built out to iterate through the ItemCollection to build out batch command 
            $command = '<Method><SetList Scope="Request">' +   
                $spList.ID +'</SetList><SetVar Name="ID">{0}</SetVar>' +   
                '<SetVar Name="Cmd">Delete</SetVar></Method>';    
            foreach ($item in $spListItemCollection)   
            { 
                $batchRemove += $command -f $item.Id;   
            }   
            $batchRemove += "</Batch>";    
             
            ## Remove the list items using the batch command  
            $spList.ParentWeb.ProcessBatchData($batchRemove) | Out-Null 
 
        } until ( $spList.GetItems().Count -eq 0 ) 
    } 
    Else 
    { 
        Write-Host $Error[0] 
        return $null  
    } 
 
    ## Dispose SPWeb object, it's just good manners 
    $spWeb.Dispose()  
} 
 
$confirm = Read-Host "This script will delete all items from the list, Proceed [y/n]" 
if ($confirm -ne 'y') 
{ 
    Exit 
}     
TruncateSPList 
 
 
 
 

Prerequisite

Windows PowerShell 2.0

Microsoft SharePoint 2010 PowerShell Snapin

SharePoint–Use PowerShell To Delete Audit Data From Farm

One of the companies I work for is very conscientious about the amount of resources used in their development and QA environments.  They also like to have their SDLC farms as close to production as possible without having to take up additional space that comes with a production farm, such as versions and audit data.  We can usually get a copy of the production database to mount to our SDLC farms, but we don’t need to take up all that space if we don’t have to.

Removing versions from the farm is explained here: http://iedaddy.com/2011/11/sharepoint-powershelldelete-old-versions-of-documents-and-items/

It is a pretty straight forward command to limit/remove the number of versions on lists that have the feature turned on to one copy of the previous version where applicable.

Now another set of production data we don’t need is the auditing data.  In order to remove this I use the following script, where the $user is set to your login ID as the Site Collection admin:

$user = "<doman\user>" foreach ($site in get-spsite -Limit ALL) { if (($site.Owner.UserLogin -eq $user) -OR ($site.SecondaryContact.UserLogin -eq $user)) { Write-host 'Deleting audit data for site: ' $sc.URL $i = -350 do { Write-Host $site.URL ' - Delete day ' $i ' : ' ([System.DateTime]::Now.ToLocalTime().AddDays($i)) $site.audit.deleteentries([System.DateTime]::Now.ToLocalTime().AddDays($i)) $site.audit.update() $i++ } while ($i -le 1) }

$site.Dispose() }

The reason I check to see if I’m a site collection admin is that the Farm also includes mySites, so when run on a site where the $user is not a Site Collection admin we’ll end up getting an ugly red warning about permission denied.  The reason I loop through each day is so that the delete is quick and if I have a farm with a lot of auditing turned on the transaction logs won’t choke and run out of room.