| Mark's profileMark Sheppard's SpaceBlogLists | Help |
Mark Sheppard's SpaceOccasional musings about dissimilar technology January 28 Goodbye Windows Live Spaces – Hello CaptainLiteral.NET!I'm moving my blog away from Windows Live Spaces to CaptainLiteral.NET, so if anybody has subscribed to my feed, then you'd best update it to point at http://feeds.feedburner.com/CaptainLiteral. I've also set-up a FeedBurner thing for my RSS, so people won't be hit by changes in the future. Why Captain Literal? The guys as work call me Captain Literal because lunchtime conversations' can go something like this: Before I go out on a rant and document why I'm moving away from Spaces, I first need to thank Ashleigh (http://www.nakedcleaner.com) for firstly, hosting CaptainLiteral.NET. Secondly, for forcing me to setup CaptainLiteral.NET. And thirdly, for spending time last night actually setting up CaptainLIteral.NET – thanks Ashleigh. And now for the fun bit – why am I leaving Windows Live Spaces? Live Spaces has some things that merely annoying – these are the things that one can live with. But it also has some things that are very annoying – things that, when realised, encourage you to drop Windows Live Spaces and go look for some other blog provisioning service or friend to host for you. The merely annoying stuff (in no particular order):
But the killer, the one that got me to move blog was that fact that you can't upload non-image files! So when I posted Sudoku vs. PowerShell last week and wanted to upload 3 simple text files, I couldn't! again, Ashleigh came to the rescue and allowed me to host the files on his other blog (http://www.f1-blog.co.uk) – thanks again Ashleigh. Anyway, now that's off my chest, I hope to see you over at CaptainLIteral.NET – where I intend to blog more often as I've realised that I actually have quite a lot to say in the technology space. I will not be posting personal posts as I really don't have an interesting life unlike professionals (aka celebrities.) January 23 Sudoku Vs PowerShellI've been obsessed since Adrian (ps1.soapyfrog.com) posted his Sudoku solving PowerShell script a couple of weeks ago. When I first read his post on the subject, I pulled down his script and ran it - at the time he didn't know how long it would take to solve the harder of the two puzzles he posted - after about an hour PowerShell had crashed on my computer! Since then Adrian has posted saying that his script takes 1.2 days to solve his harder puzzle! Having peeked at his script I quickly discovered that it works on a brute-force principle (i.e. if you don't know what number you should have in a square, guess), this seemed to work well for the easier of his samples (solved in less than a second). I decided that I'd see if I could do better and learn a few things along the way. And so started my obsession with implementing a speedy Sudoku solver in PowerShell – this shouldn't have taken two weeks, but work, life and a couple of other things got in the way. I swear, I don't know how people play with technology and constantly post about it. To start with, I had no idea how to solve a Sudoku puzzle with a computer, yet alone in PowerShell – Enter a trusty search engine to the rescue. I quickly found Andrew's Sudoku solver. Now, what's interesting about Andrew's site is that he not only solves Sudoku, he shows you step by step how to do it and he's published over 30 different strategies for solving Sudoku, complete with pictures. J Armed with details of how to solve Sudoku, I set about scripting it and making it perform better than the couple of minutes it took when I first solved the problem. In the end I got the script to solve Adrian's hard puzzle in 12 seconds – not bad! For a comparison I ported the script into C# and got it to solve the same puzzle in less than 0.1 seconds. Now, I know that PowerShell isn't designed for processing performance, but rather admin performance, but it's important to know the limits of a piece of software so you can get the right tool out of the toolbox when you need it. The C# port was written as a static and I just invoked it directly from within PowerShell and has the exact same output as from a .ps1 script – I could just have easily written this as a cmdlet. Fortunately, I only had to implement a few of the "basic" strategies described on Andrew's site to solve the harder puzzle – some of the advanced strategies didn't look like they'd be fun to implement. I've taken this script as far as I want to take it and learnt a lot about PowerShell and the way it works. My lessons and observations will form the thesis of a blog post to follow in the next few days. In the meantime, here's my solve-sudoku script, Adrian's original simple puzzle and his original hard puzzle for you to play with. Just execute the script specifying the puzzle to solve as an argument (.\solve-Sudoku.ps1 profile-puzzle.txt) January 02 PowerShell Community Extensions and x64PowerShell Community Extensions is a great addition to PowerShell that supplements the out-of-the box set of cmdlets. However, it doesn't work out-of-the-msi on an x64 platform. When installing, I opted to use the Shared Profile, but got the following when I tried to run PowerShell: Windows PowerShell Well the snap-in isn't registered on my system, let's try PowerShell (32bit): Windows PowerShell Works with no troubles. Fortunately this is easy to fix, the installer used for Pscx is a 32bit process and doesn't invoke the 64bit version of InstallUtil.exe to register the snap-in for 64bit processes. Just run the following from your favourite shell: [C:\Documents and Settings\Mark] Restart PowerShell and everything is good for both 32bit and 64bit PowerShell :) I have raised this as an issue on site. Hopefully they'll fix it on the next release. PowerShell System UptimeI just needed to know how long it was since my box was last rebooted. Windows Vista has a nice feature where this is now a property of the Performance tab in Task Manager. But alas, there's no such nice functionality in Windows 2K3. Usually I end up in PerfMon to get the number of seconds the box has been up and then in calculator to convert this into real time. Enter PowerShell to the rescue: function GLOBAL:Get-SystemBootupTime([String]$computer="localhost") { Not bad, I can now see the system uptime in seconds, but I want the result formatted function GLOBAL:Get-SystemUptimeFormatted([String]$computer="localhost") { Job done! As a developer, I tend towards using .NET all over, so I've probably missed some rather subtle ways of achieving the formatting with PowerShell. You can get a lot of other useful information from the WMI classes that could be the focus of other functions: PS C:\> $computer = "localhost" To ensure that this handy set of functions is always there when needed, I've added them to my profile: PS C:\> Notepad $profile
September 11 Windows PowerShell ResourcesWindows PowerShell is an fantastic tool that will become part of my “used daily” toolkit. I came across Jeffrey Snover’s blog a couple of weeks ago and have really enjoyed reading it. I also recommend the 10 part series on managing Active Directory with powerShell on the /\/\o\/\/ PowerShelled blog, it is very insightful but I felt that I need something more basic to learn the product from the ground up. Enter Jeffrey's recently published presentation (from tech-Ed 2006) on PowerShell – this guy makes an hour and 15 minutes of the command line amusing to watch and very informative. I’d prescribe it to all IT Pros as this is going to be your tool of choice in the future. A couple of things stand out from the presentation. One is that all other scripting mechanism shipped with windows are “feature complete” and two is that in Exchange 2007 (E 12), the MMC admin interface calls PowerShell to perform functions. The implications of the first one are massive, cscript/wscript/WSH will not be extended in the future and CMD will not get any more features added! PowerShell will be the ONLY scripting tool for admin scripting and will I imagine replace CMD. This is a big shift and if you don’t embrace PowerShell in the Longhorn Server timeframe, you’ll find yourself without any scripting tools and without any community support! The second part (E 12 using PowerShell for all admin) is intriguing from the point of view of a developer (like me), He only talked about it briefly, but I got the impression that all the MMC snap-in for E12 does is call PowerShell – this means that anything you can do in the GUI, you can do from the console. I want to implement this in my applications! Better still, the E 12 GUI will tell you the PowerShell command to achieve what you’re trying to do, rather like SQL 2005 having a Script button whenever you do something – how cool is that? This is something I can take advantage of in applications and try to get the ops guys to use PowerShell in favour of the GUI in the future. Right now, Windows PowerShell is in Release Candidate and I imagine that it’ll ship when Vista does, maybe I should raise the chage to get it deployed all over the companies servers now and see if it gets approved |
This site has moved to http://www.captainliteral.net
|
|||||||||||||||||||||||||
|
|