• Newly deployed SharePoint site definitions not found in PowerShell

    Tags: SharePoint 2013, PowerShell, SharePoint

    This is a new problem for me, something that I have done many times in SharePoint 2010.  I deploy a new site definition to SharePoint (in this case from Visual Studio 2012, although I can’t see it will matters), pop into PowerShell (in my case I use PowerGUI) and try to create a site from the new definition.

    However, when in PowerShell, running a script similar to this

    $web = Get-SPWeb $SiteURL
    $templates = $web.GetAvailableWebTemplates(1033)
    $templates | Foreach {
    	Write-Host $_.Name
    }

    You find that your new site definition is not listed in with all the other templates.

    Go and look in SharePoint, create a site and bingo, it’s there.  Weird.

    The problem is around caching in PowerShell sessions.

    Restarting IIS and SQL service didn’t work, so I had a quick Google and found this post.

    What a pain…so I quickly (with the help of this article) created a PowerShell cmdlet.

    Note: Make sure when you run the x64 version of InstallUtil (with from the VS x64 command line or C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe) otherwise you wont find it when you run

    Get-PSSnapin –registered

     

    Confused

    I’m not entirely sure why I have never come up against this before having done it multiple times, perhaps its an update to PowerGUI and the way it handles sessions or perhaps it’s a change in SharePoint 2013 caching.  I don’t know!

     

    Code for the PlugIn

    Copied from the link above!.  Don’t forget to add a reference to System.Management.Automation (C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\System.Management.Automation.dll) and Microsoft.SharePoint

    [Cmdlet(VerbsCommon.Reset, "SPContext")]
    public class RecycleSPContext : PSCmdlet
    {
            
        [DllImport("kernel32.dll")]
        private static extern IntPtr FreeLibrary(IntPtr library);
    
        [DllImport("kernel32.dll")]
        private static extern IntPtr GetModuleHandle(string lpModuleName);
    
        [DllImport("kernel32.dll")]
        private static extern IntPtr LoadLibrary(string lpFileName);
            
    
        protected override void ProcessRecord()
        {
            Type sprequestmanager = typeof(SPFarm).Assembly.GetType("Microsoft.SharePoint.SPRequestManager", true, true);
            Type spthreadcontext = sprequestmanager.Assembly.GetType("Microsoft.SharePoint.Utilities.SPThreadContext");
            MethodInfo setcontext = spthreadcontext.GetMethod("Set", BindingFlags.Static | BindingFlags.NonPublic);
            Type[] genericArguments = new Type[] { sprequestmanager };
            MethodInfo setcontextgeneric = setcontext.MakeGenericMethod(genericArguments);
            // set the current sprequest manager to null!
            setcontextgeneric.Invoke(null, new object[] { null });
    
            IntPtr p = GetModuleHandle("OWSSVR.DLL");
            FreeLibrary(p);
            string stsadmPath = SPUtility.GetVersionedGenericSetupPath("ISAPI", 15);
            p = LoadLibrary(stsadmPath + @"\OWSSVR.DLL");
                
            WriteObject("SharePoint context restarted at " + DateTime.Now.ToString());
        }
    
    }

     

    And the Installer

    [RunInstaller(true)]
    public class RecycleSPContextInstaller : PSSnapIn
    {
        public override string Description
        {
            get { return "Recycle the SP Context"; }
        }
        public override string Name
        {
            get { return "RecycleSPContext"; }
        }
        public override string Vendor
        {
            get { return "Vendor Name"; }
        }
    }

    more...

  • Kendo UI grid – disable row select on command button

    Tags: kendoui, jQuery, web dev

    Kendo UI - The way of HTML5Recently I’ve been working more and more with the Kendo UI components.

    For those that don’t know, Kendo UI is a collection of HTML 5 controls from the wizards at Telerik.

    As with most controls, especially new ones like Kendo.  You find the demos look great and everything seems awesome, but when using in the real world you hit hurdles that are just not covered.

    And that is where I find myself.  I have a grid, with a custom command button, I also have row selection enabled.  I want to run separate commands on row select and the button, but Kendo UI will always execute the row select command (grid change event), even if you are hitting a command button.  I’m sure in some cases that will be fine, but it’s not ideal for me.

    So after a some poking around I found this answer on stackoverflow.

    As mentioned in the above link, this is not supported by the control as yet, so the answer as per that post is to tweak around with the CSS and javascript.  It’s not the most elegant of solutions, but this is javascript, anything is possible … elegance sometimes takes a back seat!

    Command column definition:
    Setting the class to actions being key here!

    ... 
    selectable: "row",
    change: onRowSelect,
    columns: [
    {
       command: [{
       	name: "Edit", click: function (e) {
            	console.log("edit clicked");
                    e.preventDefault();
                    var item = this.dataItem($(e.currentTarget).closest("tr"));
    
    		// Remove row selected class
                    $(e.currentTarget).closest("tr").removeClass("k-state-selected");                
                    // Do something...
            }
       }], title: " ", width: "50px", attributes: { "class": "actions" }
    },
    ...
    

     

    Change event handler:
    Taken from stackoverflow

    function onRowSelect(arg) {
                var eventTarget = (event.target) ? $(event.target) : $(event.srcElement);
                var isAction = eventTarget.parent().hasClass('actions');
    
                if (isAction) {
                    console.log("Command button hit");
                    return;
                }
                // Do what you want for row select
    ....

    more...

  • Installing Windows 2012 on VMWare 8

    Tags: vmware, Windows 2012

    This seems like a simple task, but considering the problems I had, I thought I’d just knock out a quick post!

    VMWare 8 is not the latest version, so perhaps this is ironed out somewhat in version 9!?

    I went through the normal steps of Create new VM, pointed at my Win 2012 ISO and away we go…

    First error

    Windows cannot read the <Product Key> setting from the unattend answer file

    This causes a continuous boot loop.

    Source: http://scle.me/1di8W7B

    Resolution: disable the floppy drive.

    Windows should install fine now!

    Second error

    Trying installing VMWare tools

    VMware Tools installation cannot be started manually while the easy install is in progress.

    Source: http://scle.me/1di8KFD

    Resolution: enable the floppy drive again!!!!

    Third Error

    Black screen after installing VMWare tools.

    Source: http://scle.me/12hiyut

    Resolution: Enable graphics acceleration

     

    Hope this helps!

    more...

  • Finding cycling routes

    Tags: Training, Triathlon, cycling, milton keynes

    Having recently moved to a new city, in fact a whole new country!  Well, technically not new as I’ve moved back to the UK from the Cayman Islands, but a city in the UK where I have never lived before.

    As any self respecting cyclist/triathlete would do, I immediately joined the local club.  Obviously this is a great way to meet local people with similar interests and a way to learn about the local area.

    However I found myself wanting when it came to searching out cycle routes.  I’m all for just going out and having a ride, but that does have its downsides. 

      1. MK is quite special and with so many dual carriageways and main roads it’s sometimes not just a case of jumping on and riding round. 
      2. I’m training for the London Triathlon in July and I want to be able to train for a certain time, distance and terrain.

     

    First stop for me was the local club’s (TeamMK) forum.  It was suggested that not only do they have some routes on the site, but to join Strava and link to the Team MK.  I’m on Strava and so I linked to Team MK and true enough I found numerous routes.  Premium members can download the gpx, but I am not, so I was stuck with just looking on the screen.

    Being able to download the gpx is great idea, I can put it on my Garmin 500 and (after some app searching) I can put in on my phone (via email) and open in a little *free* app called GPX Tracker (this is a very simple app, it basically just draws the route on a map and shows where you are …  so does what I require!!

    imageUsing the GPS on the Garmin 500 is not as good as the 800 or 810.  You don’t get maps, you simply get a black line on the screen and prompted where and when to turn – when its not messing around looking for signal … which does happen and of course at the wrong times!!

    I still didn’t have any gpx routes without joining Strava premium, I’m sure there are many out there, but I found ridewithgps.com and searched for local routes, of which I found quite a few.

    The perfect solution!!  Kind of – having the map on the Garmin means you can see your stats that you're used to (speed, cadence etc) and having it on the phone means you have to keep checking, waiting for the map to refresh etc.  All of this does affect the training, I found it hard to get into a rhythm and bang out the miles. 

    Still – a lot of fun!!!  Geeky, training fun – the best kind Smile

    more...

  • Windows Phone 8, 1 month in…

    Tags: windows phone 8, WP8, iphone

    HTC-X8

    After being an iPhone user since v2 (I skipped the non-3G v1 effort)  I recently decided to jump ship and try Windows Phone 8.

    The iPhone experience, although tweaked here and there over the years, has largely remained the same and I was a bit bored of it.

    I went for a HTC 8x, three main reasons…

    • Rave reviews
    • The Nokia 920 was only available (when I bought it in the UK) locked to Orange and associated networks.  I wanted to take it back the Cayman Islands!
    • Although big (smaller than the Nokia 920 though), it does feel pretty slick.

     

    Rather than writing a novel on the subject, I’m just going to push out some bullet points.

    The good ( OS )

    • The WP8 UI is beautiful, its smooth and very modern. 
    • I love how my social networks are integrated directly into the phone, in the people hub for example.  This is a big plus.
    • Contact pictures auto downloaded and merging contacts works well.
    • Live tiles, love this.  Seeing a little calendar, weather etc info directly on the tile.
    • Maps – although not better than the Google maps on iOS, considerably better than Apple’s disgraceful effort in iOS 6.

     

    The bad ( OS )

    • Apps, apps, apps.  The app store has pretty slim pickings, although the main contenders are there, its clear the investment in developing those apps (like Facebook, whats app, BBC news) is pretty poor as they are simply crap compared to the iOS version.  To the point that they just don’t function correctly, let alone poorly.  Although not directly a fault of the phone…it hurts the WP8 eco system.
    • Slow, I don’t mean the OS itself, which is very snappy.  Refreshing data in apps, opening web pages, its just slower than the iPhone.
    • Search.  Why the hell does that search button default to the web?  It should search my phone first, then the web.
    • Mail live tile.  Shows number of new items, going into the app, whether i read them or not, removes that number.  That’s crap.
    • The keyboard and auto-correct is not good.  I make more typo’s than ever before. 
    • Closing apps.  Perhaps this is me, I’m missing something.  But I want to force the closure of apps.  Mainly because they are crap and need to restart in order to refresh.  How?!

     

    As a user of the MS online eco system (live mail, skydrive etc) I would say that the WP8 integrates really well with that, but iOS has some nice apps that do the same.

     

    The good ( Phone )

    • Great to hold, love the feel of it.
    • Screen is really clear
    • Although quite big, its really thin and fits really well into a pocket.

     

    The bad ( Phone )

    • The buttons for power, volume, camera are just not good.
    • The phone is too big to operate well with one hand.  I can’t hit the power/lock button without pressing the camera button.
    • The battery is poor.  I’m lucky to get a day from it.  On my iPhone 4 a day was easy…i could stretch it out.
    • The camera, although the MP is high, getting a good shot is tricky…you need a very steady hand.  This might be the OS, but still…its not great.

     

    In general I am pretty happy.  I don’t think the WP8 is as good as an iPhone.  In software or hardware.  Perhaps with some investment in apps it will be better.

    I’m happy to be using something different from an iPhone though – a change was needed.

    On another note, I’ve recently been given a Blackberry from work…now that is total rubbish!!!!!!!

    more...

  • Lance Armstrong–such a shame…

    Tags: Training, Triathlon, IMO

    This is obviously all over the news at the moment, I for one find it disappointing reading about it (BBC article - http://scle.me/T5gHDV ) .

    I can’t really understand the thinking behind it.  This goes back a long way, and they appear to have no proof other than the word of other people – which as we all know is not proof.  Of course you can’t allow a doper to simply be “allowed” because of who he is.  But this all happened a long long time ago – and they don’t appear to have conclusive evidence.

    I understand his comment, he must be tired of fighting you and as he gets older why would he want to continue fighting and fighting.  He wants to enjoy time with his family, I would too.

    I think Lance is an icon, an inspiration (albeit with an arrogant American approach), what he has achieved and continues to achieve racing in Triathlons in quite incredible.

    He is a credit to your country and done a many great things for a great many people.

    more...

  • Cayman Stroke and Stride–Race 2

    Tags: Triathlon, Cayman, Training

    SaS-R2

     

    After a bit of a bad start to the set of 3 races, last night went a lot better.  For a start I made sure I had plenty of battery in my watch.

    I decided to go for it a lot more with the swim, I still started near the back and on the wing, I’m not a great swimmer, but I’m better then my effort last week.

    I wasn’t so shocked by the amount of arms and legs flying all over the place and stuck to my task, although still not in my normal rhythm,  I don’t think I ever will be!!  I soon started catching and overtaking people.  Trying to draft where I could, but I couldn’t seem to find the right person to draft.  Either too slow or too fast.

    The current was against us on the way out, and you could certainly feel it!  After the turn, bodies were spread out, with the current behind us it was certainly easier.

    I finished the swim in just under 12mins, still a very slow time for a swimmer, I was probably 4-5 mins behind the leader.  That’s still at least 2 mins slower than I would do it in a pool!

    Transition took me just over a minute, I was never going to be fast.  I don’t have “quick” laces, I have to double knot my trainers and with wet feet and hands,  it’s tricky! I also need a good drink because the taste of salt water is horrible!  Most people that come out of the water with me or just after me started the run before me!!   I wasn’t worried in the slightest about that!  Some of these guys are very serious!

    The run went pretty much as standard!  I certainly would like to have run faster, but the heat is a big factor for me, I’m not a small slim guy.  I weigh over 80kg and not having been here long, I overheat … a lot!

    Thoughts that stick…

    • The guys and gals in Cayman are quite elitist and serious about their training.  There are not many “have-a-go” people here in the races.  Apparently its the same crowd for all these types of events.  Bugger!
    • I don’t like running straight out of the water.  Wet feet don’t make it overly comfortable and my heart rate doesn’t get chance to recover like it does on the bike – which is probably my strongest event anyway…so I miss the ground I can make up after my slow swim!  Also, I don’t like my nice trainers getting so wet!!!!

     

    Next week is the final race in this Series.  The swim goes up to 800m.

    Then the Triathlon build-up (practice) events start.  Which include a bike leg!  I’m looking forward to that!

    more...