Friday, December 28, 2007

Writing Cmdlets for Windows PowerShell

I've just seen a cool article on Bennie's Weblog over on the Foo Theory site. Entitled Writing Custom Cmdlets for Windows PowerShell, it is a long and involved piece covering both some intro material on PowerShell plus full details on how to create a new Cmdlet using Visual Studio.

Thursday, December 20, 2007

Jerome's Place Bit Torrent Site

As many of my friends know, I collect Jerry Garcia and Grateful Dead live shows. I've got just over 1060 live Dead shows, and just under 400 Jerry Garcia shows. Several thousand hours of great music (plus it has to be said, many hours of not so good music - not every show was good!).

I have access to a private bit torrent site, Jerome's Place which shares this music to a small fanatical fraternity of dead heads. The site is looking for some new users, and I've just been provided some invites. If you are a trusthworthy Dead or Jerry fan, have reasonable bandwidth and want access to this treasure trove, send me an email. 'll happily pass one your way as long as the invites last!

[Later - August 2009]

Sadly, Jerome's Place has gone to join Jerry in that great music site in the sky and is no more. I've still got the music I've downloaded from that site, so if you want a copy, contact me and we can work something out.

Tuesday, December 18, 2007

Updated Windows PowerShell Online

Admittedly, the URL http://technet.microsoft.com/en-us/library/bb978526.aspx does not readily roll off the tongue. So PowerShell users should book mark this page. Microsoft has just updated the TechNet site with the full PowerShell help files. Better yet, these are the latest updates and include fixes, etc. Thanks to superstar June Blender for getting this done.

If the help isn't clear enough for you, use the feedback mechanism to leave a comment. I'm sure these will be actioned as quickly as possible!

Technorati tags: ,

Getting Hot Fixes for Windows

I wrote last spring about the problems IT Pros can have with getting hot fixes for Microsoft products. I pointed out a Microsoft provided web site that you could use to get a hot fix. Thanks to a comment on my earlier blog article from MSMQ guru John Breakwell, I see that this hot fix web page has been retired.

As John notes in a recent blog article, Microsoft has replaced the web page with something a whole lot better - the hot fixes are now linked directly from the KB article page - something long overdue IMHO!

Thanks John for pointing out this change.

Technorati tags: , ,

Thursday, December 13, 2007

Microsoft Releases Windows Server 2008 RC1 Public Beta

In a pre-christmas peice of generousity, Microsoft has released Windows Server 2008 RC1 to the general public. See the Microsoft web site to download the code and to get a license key. The software is a 30-day evaluation version, but you can get a key for a longer evaluation period.

Wednesday, December 05, 2007

Microsoft to modify Windows Genuine Advantage anti-piracy scheme

Microsoft has agreed to modify it's much reviled anti-piracy scheme. As noted on Mary Jo's blog, Microsoft has is to modify Windows Genuine Advantage scheme to drop the "reduced functionality mode". At last, Redmond is seeing sense over this! Mary Jo goes on to say "Microsoft will introduce the changes to future test builds of Windows SP 1 before the final version is released in the first quarter of 2008. Ditto with Windows Server 2008 — the current Windows Server 2008 test builds do not include the WGA changes, but some future builds will."

Technorati tags: ,

Monday, December 03, 2007

OCS Voice Ignite - going to Orlando

Just got the final confirmation through today - I'm heading off to Orlando on Saturday to attend the OCS Voice Ignite event that I wrote about recently. I hit Orlando late on Saturday night, with a day to hang out with the Global Knowledge crew (and hopefully some rest) before 5 days of deep, deep technical OCS voice stuff. I've started looking at the labs - I can't wait.

I'm booked to help the team re-deliver this in Barcelona (I suspect I'll be a lab rat or similar). And I may also be Australia bound to help re-deliver parts of this seminar in Sydney. So it looks like some fun travel coming up soon!

Technorati tags: ,

What it means to be out of beta (Eurekster Blog)

Not long after posting an article about Swikis, I read this article on the Eurekster blog: What it means to be out of beta (Eurekster Blog) noting that the swiki platform is out of beta. It's an interesting business model - I wish them well.

Technorati tags: ,

Swiki - from Eurekster

A swiki is a "custom social search portal on a topic of your choice", says Eurekster.com. In effect, a swiki is a widget you put into a web page and chose the topics that you are interested in. Eurekster then creates a tag cloud based on the tags you supply. What's nice is that as others use your swiki, they can vote on certain search hits, to help the gadget generates more and more relevant content.

I've been playing around with this and have created a PowerShell-Stuff swiki, and have placed it onto this blog. I've also put an OCS-Stuff swiki over on my corporate blog. are these useful/interesting/helpful??

Technorati tags: , ,

Visual Studio 2008 Training Kit Requires PowerShell

Super star PowerShell MVP Keith Hill has made an interesting find in Visual Studio's 2008 recent release - it needs PowerShell. Keith describes his find over on his excellent PowerShell focused blog: Visual Studio 2008 Training Kit Requires PowerShell.

Thanks for the find Keith (and thanks for your great blog too!).

Sunday, December 02, 2007

SecPol in Vista Home Premium - there isn't any!

As Susan Bradley has discovered is: There's no secpol in Vista Home Premium and she asks the all important question - now what. Naturally, Susan provides a neat answer - just hack the registry.

This tip will come in handy - I'm getting my wife a new computer and it'll come with Vista loaded and I want to not have to have her deal with UAC.

Thanks Susan.

Windows Live Writer: Out of Beta

As noted over on the Windows Live Writer blog: Windows Live Writer is out of Beta! I've been using this tool for a while as my principal blogging tool. It rocks!

Technorati Tags:

Thursday, November 29, 2007

TechNet Plus Subscription Offer: Great Bargain, Much Cheapness (US only)

While there's not much time left, Microsoft's just posted a pretty cool TechNet Plus Subscription Offer. For a very limited time, you can pick up a 1-year subscription to TechNet Plus for US$279.

Sadly, although I saw this in the UK flash, it looks like this offer is US only. :-( Hey Microsoft - that's poor. I hate that MS send me an offer in email  that I can't actually use. It might be a nice touch, given the crazy exchange rate MS software is sold at here in UK (i.e. nearer 1$=1£, versus $2.05 to the £ that the FEX is offering). But I digress. TechNet Plus is a great product for IT pros, even at the inflated prices in the UK.

Technorati tags: , ,

2008 Scripting Games - Coming Soon!

With the holiday season ahead of us, things happening in the new year seem very far away. However, commencing in mid-February 2008, Microsoft is bringing us the 2008 Scripting Games. I suppose that if you have to ask what the scripting games are, then you’ve obviously been missing out over the last two years. Oh - and apparently it's not just about PowerShell!

The Scripting Games are a chance to practice and test your scripting skills. The Games are live: contestants submit entries that are judged and scored. You’ll be eligible to win prizes based on simply entering, or based on your score.

The Scripting Games run from 15 Feb 2008 through 3 March 2008, so put those dates into your diary now!

Sunday, November 25, 2007

Download details: Office Communications Server 2007 Security Guide

Yet more documentation from the OCS team. In this case, the Office Communications Server 2007 Security Guide which is a 42-page document describing the security aspects and features of OCS 2007. This is a must read for all OCS admins!

Tuesday, November 20, 2007

Microsoft Releases Visual Studio 2008

The first of "the big 3" to actually be released (along with SQL Server 2008 and Windows Server 2008) - Redmond Mag reports that Microsoft Releases Visual Studio 2008. I know what I'll be doing over the next couple of days!

Technorati tags: ,

More Updates to Windows Vista available via Windows Update this week

As reported on the Windows Vista Team Blog : New Updates to Windows Vista available via Windows Update this week, there are several new updates for Vista due out soon via Windows Update. These fixes are pre-SP1, and are being made available now.

It's great that MS is pushing out updates. Personally, I'd prefer XP SP3, but that's just me.

Technorati tags:

Wednesday, November 14, 2007

TechEd - More on Windows Virtulisation

I attended a panel session on Virtulisation - a panel discussion with Mike  Neil (MS), Simon Husby (Citrix), Larry LeSueur (MS), BIll Corgan (MS).

Server virtulisation is something that's getting lots of attention - many good reasons for dong it. But Server virtulisation is only in it's infancy, and is only a part of the overall Virtulisation story. This includes presentation virtulisation (e.g. terminal server/citrix), and application virtulisation (eg SoftGrid). MS said that they've sold 3m seats of SoftGrid in past 2 quarters!

Simon made the point is that the virtulisation market is still fairly new. He also noted the importance of supporting Linux in terms of virtulisation - and management is important. He went on to discuss the integration of Xen and Citrix - and re-itereated Citrix's support of the Windows platform ("We have no OS agenda"). Interoperability continues to be a key aspect of their products.

Regarding desktop virtulisation - there are three aspects:

  • Terminal Services's Remote App (in WS08) - useful in a variety of scenarios
  • Vista centralised desktop - hosted desktop run in the data centre, remoted to a thin client
  • Application virtulisation (i.e. SoftGrid).

Mike spoke about desktop (VPC) virtulisation. He said that MS sill value VPC. I raised the issue of missing feature (e.g multiple CPUs, USB support, 64-bit support). These are very important to us. Mike acknowledged the concerns but made no commitment to providing those missing features.

Mike also discussed Hyper-V vs VMware. He talked about the benefits of open APIs, a large partner ecosystem along with the management tools. With VMware, the panel suggested, you are left with VMware and little else - there is not any sort of robust eco-system. MS, on the other hand, has a richer partner model. Simon suggested that the introduction of choice (i.e. Hyper-V) will help the market mature. Larry pointed out the importance of good management tools (i.e. System Center).

Technorati tags: ,

Monday, November 12, 2007

TechEd Barcelona - Keynote Announcements

Today is the first day of TechEd-IT Form and as usual,there's a keynote. And as usual, there were loads of demos (most worked). And in a change form last year, the session finished on time!

Microsoft used the keynote to make a number of key product announcements. These include:

Windows Server 2008

  • Hypervisor naming. Viridian was the code name - now it's officially named Microsoft  Hyper-V. A stand alone server for virtulisation was also announced as Hyper-V Server.
  • Dates for release of WS08 are still "WS08 in Q1 2008 with Hyper-V 180 days later!
  • MS is to release 8 Ws08 SKUs. Three of these come with Hyper-v built in, five don't. "This gives users lots of choice" said the MS person! The three SKUs with Hyper-V are : Enterprise, Standard Edition, Data Centre edition. The five that ship without Hyper-V: Standard Edition Without Hyper-V, Enterprise Edition without Hyper-V, DC without Hyper-V, Web, and Itanium Edition.
  • Pricing and licensing was also released. Costs are roughly 1 more than for Windows Server 2003! The difference in cost between the Hyper-V and non-Hyper-V systems is US$28!
  • At RTM, the Hyper-V beta bits will ship in the box. Hype-V RTM bits then ship 6 months later via Windows Update
  • Virtulisation Validation program - helps to ensure virtulisation works

System Center

  • General Availability  of 3 products: SC Configuration Manager 2007 (aka SMS), SC Virtual Machine Manager and SC Data Protection Manager 2007 (joined  by SC Operations Manager released earlier this year).
  • New System Center Suite licence (licensed per physical server, manage unlimited guests)
  • System Center Alliance - a community effort to promote System Center
  • VM Manager (a future version) will also support both Hyper-V VMs and VMware VMs! This means you can manage ESX servers from Windows.

SQL

  • Release to be in 2nd quarter of 2008.
  • New SQL Server CTP - November CTP. This is to be the penultimate CTP prior to release.

Vista

  • Formal announcement of the beta of next release of application virtulisation approach (the stuff bought in from Softtricity and available only to volume license customers). Version 4.5 beta should be up on Connect.
  • Microsoft Desktop Optimisation Package fastest moving SA product ever - but not available outside SA. MS still bullish on SA and MDOP.

PowerShell

  • CTP for Version 2 is now available.

IIS6

  • FastCGI extension for IIS 6 - makes PHP run even better.

Centro

  • Centro was announced as "Windows Essentials Business Server 2008". Centro won't ship till end of 2008.

Community Efforts

  • A set of announcements around MSDN and TechNet - more content, more communities, etc. New site: "TechNet Edge" (http://edge.technet.com).

 

Technorati tags: , , , ,

TechEd Barcelona - The Event Commences

I'm here in nearly Sunny  Barcelona for TechEd-IT Forum, Microsoft's travelling technology show. I find TechEd a great time to sit back, relax and take stock of things. This is a chance to reflect on what's new and exciting and look forward to see how these technologies might unfold over the coming year(s). In the days of being a freelancer, I also used TechEd to work out what would keep me in work for the coming year.

Unlike in previous years, the Keynote is not until 14:00 on the first day. I suppose this gives folks a chance to get here from the rest of Europe and avoid the Sunday night stay, but it means not much is happening thus far. The press office is unusually quiet!

This year's keynote is being delivered by Bob Kelly, a Corporate Vice President in charge of Infrastructure Server Marketing. I've not heard him speak or seen his speech yet, but with a title like that, I suspect the talk will concentrate on Server 2008. I sure hope he keeps the talk marginally marketing free and concentrates on the IT Pro's view of the product. I also really hope he starts, and finishes on time! I'll report back after the session.

Unlike in previous years, the Keynote is not until 14:00 on the first day. I suppose this gives folks a chance to get here from the rest of Europe and avoid the Sunday night stay, but it means not much is happening thus far.

Technorati tags: , ,

Sunday, November 11, 2007

Formatting with PowerShell

One of the great features of PowerShell is that much formatting is done for free. For example, to find out the size of a particular file you could just enter:

PSH [D:\foo]: ls demo-format.txt

    Directory: Microsoft.PowerShell.Core\FileSystem::D:\foo

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        11/11/2007     12:26       2008 demo-format.txt

In most cases, that's good enough - you can see the file size is 2008 bytes long. But suppose you wanted to know how big the file was in GB, or to print it out in a nicely formatted layout. Using some of PowerShell's .NET underpinnings, this turns out to be easy to achieve with what .NET calls Composite Formatting.

With composite formatting, you get PowerShell to format one or  more values as a pretty string, and insert this string (or strings) into a  into a string known formally as a composite formatting string. The composite format string contains any text you specify, along one one or more place holders,  known as format items. PowerShell creates a result string that has the original text you specified along with string representations of the objects in the list.

An example composite format string might be:

"This is stuff{0} and more {1} stuff and more {2}"

This format string has three place holders. If you use PowerShell's -F string operator you can get PowerShell to format this string with some values, as follows:

"This is stuff{0} and more {1} stuff and more {2}" -f ",", "really cool", "excellent stuff"

What PowerShell does is to take the values to the right of the -f operator, and place them into the string as indicated by the placeholders {0}, {1}. and {2}. The first variable to the right is places into {0}, the second into {1}, and the third into {2}, with the result of:

This is stuff, and more really cool stuff and more excellent stuff

The format of the placeholders, however, can be more complex than just a simple index into the array of variables. The full syntax of the placeholder is:

{index[,alignment][:formatString]}

This allows you allows you to right and left justify the value into a fixed length number of characters, as well as to use the format string to format dates, phone numbers, etc.

Rather than drone on,  here is a demo script I've knocked up to demonstrate the formatting capabilities of PowerShell.

NB: This script needs Version 2 of PowerShell (although most of the features work OK in V2).

 

[0]PS D:\foo > #REQUIRES -Version 2
[1]PS D:\foo > #
[2]PS D:\foo > # First, simple formatting
[3]PS D:\foo > $num=123.45

[4]PS D:\foo > "`$num = $num"
$num = 123.45

[5]PS D:\foo > #
[6]PS D:\foo > # Show Conversion into *b
[7]PS D:\foo > #
[8]PS D:\foo > $num=1234567890123.12345

[9]PS D:\foo > $num/1kb
1205632705.19836

[10]PS D:\foo > $num/1mb
1177375.68867028

[11]PS D:\foo > $num/1gb
1149.78094596707

[12]PS D:\foo > $num/1tb
1.12283295504596

[13]PS D:\foo > $num/1pb
0.00109651655766207

[14]PS D:\foo > #
[15]PS D:\foo > #
[16]PS D:\foo > # Demo String Format and Replace
[17]PS D:\foo > #
[18]PS D:\foo > # simple substitutions
[19]PS D:\foo > "{0}    {1}  {2}"         -f "123", 123, 234
123    123  234

[20]PS D:\foo > # or
[21]PS D:\foo > $a=1; $b=2

[22]PS D:\foo > "{0} + {1} = {2}"         -f $a, $b, $a+$b
1 + 2 = 12

[23]PS D:\foo > #
[24]PS D:\foo > # NUMBERS
[25]PS D:\foo > #
[26]PS D:\foo > $number = 12345.457

[27]PS D:\foo > # right aligned number with two decimal places
[28]PS D:\foo > #
[29]PS D:\foo > "*****`+{0,20:n2}`+*****"  -f $number
*****+           12,345.46+*****

[30]PS D:\foo > # left aligned number with two decimal places
[31]PS D:\foo > #
[32]PS D:\foo > "*****`+{0,-20:n2}`+*****" -f $number
*****+12,345.46           +*****

[33]PS D:\foo > # left aligned number with four decimal places
[34]PS D:\foo > #
[35]PS D:\foo > "*****`+{0,-20:n4}`+*****" -f $number
*****+12,345.4570         +*****

[36]PS D:\foo > #
[37]PS D:\foo > # TIME AND DATE
[38]PS D:\foo > #
[39]PS D:\foo > $date=Get-Date

[40]PS D:\foo > #12-hour format (lower case hh)
[41]PS D:\foo > "{0:hh.mm.ss tt}  "       -f $date
12.26.32 PM

[42]PS D:\foo > # 24 hour time format (upper case HH)
[43]PS D:\foo > "{0:HH:mm:ss}"            -f $date
12:26:32

[44]PS D:\foo > # Date in default format
[45]PS D:\foo > "{0}         "            -f $date
11/11/2007 12:26:32

[46]PS D:\foo > # date in a custom short format
[47]PS D:\foo > "{0:MM dd yy}"            -f $date
11 11 07

[48]PS D:\foo > # date, "month year" format
[49]PS D:\foo > "{0:MMMM yyyy}"           -f $date
November 2007

[50]PS D:\foo > # or even
[51]PS D:\foo > "{0:yyyy-MM-dd}"          -f $date
2007-11-11

[52]PS D:\foo > #
[53]PS D:\foo > # CURRENCY
[54]PS D:\foo > # basic with 2 decimal places
[55]PS D:\foo > #
[56]PS D:\foo > $money = 12345.678

[57]PS D:\foo > "{0:c2}"                   -f $money
£12,345.68

[58]PS D:\foo > # right aligned currency with two decimal places
[59]PS D:\foo > #
[60]PS D:\foo > "*****`+{0,22:c2}`+*****"   -f $money
*****+            £12,345.68+*****

[61]PS D:\foo > #
[62]PS D:\foo > # PERCENTAGES
[63]PS D:\foo > #
[64]PS D:\foo > # percent with 2 decimal places
[65]PS D:\foo > $pct = 9/29

[66]PS D:\foo > "{0:p2}"                      -f $pct
31.03 %

[67]PS D:\foo > # percent with four decimal places
[68]PS D:\foo > "{0:p4}"                      -f $pct
31.0345 %

[69]PS D:\foo > #
[70]PS D:\foo > # PHONE NUMBERS
[71]PS D:\foo > #
[72]PS D:\foo > "{0:(###)(###) ####}"         -f 4255551212
(425)(555) 1212

[73]PS D:\foo > # UK phone
[74]PS D:\foo >  "{0:(##)(###) ######}"       -f 44118123456
(44)(118) 123456

[75]PS D:\foo > #
[76]PS D:\foo > # FANCY TRICKS
[77]PS D:\foo > #
[78]PS D:\foo > # create leading zeros
[79]PS D:\foo > 0..15 | % {"{0:0##}"          -f $_}
000
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015

[80]PS D:\foo > 0..15 | % {"{0:0####}"        -f $_}
00000
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015

[81]PS D:\foo > $str="This is number"

[82]PS D:\foo > # right aligned string
[83]PS D:\foo > 0..15 | % {"`+$str {0,10}`+"  -f $_}
+This is number          0+
+This is number          1+
+This is number          2+
+This is number          3+
+This is number          4+
+This is number          5+
+This is number          6+
+This is number          7+
+This is number          8+
+This is number          9+
+This is number         10+
+This is number         11+
+This is number         12+
+This is number         13+
+This is number         14+
+This is number         15+

[84]PS D:\foo > # Left Aligned string
[85]PS D:\foo > 0..15 | % {"`+$Str {0,-10}`+" -f $_}
+This is number 0         +
+This is number 1         +
+This is number 2         +
+This is number 3         +
+This is number 4         +
+This is number 5         +
+This is number 6         +
+This is number 7         +
+This is number 8         +
+This is number 9         +
+This is number 10        +
+This is number 11        +
+This is number 12        +
+This is number 13        +
+This is number 14        +
+This is number 15        +

[86]PS D:\foo > # right & left aligned string
[87]PS D:\foo > 0..15 | % {"*** `+{0,10}`+ ***** `+{0,-10}`+ ***"   -f $_}
*** +         0+ ***** +0         + ***
*** +         1+ ***** +1         + ***
*** +         2+ ***** +2         + ***
*** +         3+ ***** +3         + ***
*** +         4+ ***** +4         + ***
*** +         5+ ***** +5         + ***
*** +         6+ ***** +6         + ***
*** +         7+ ***** +7         + ***
*** +         8+ ***** +8         + ***
*** +         9+ ***** +9         + ***
*** +        10+ ***** +10        + ***
*** +        11+ ***** +11        + ***
*** +        12+ ***** +12        + ***
*** +        13+ ***** +13        + ***
*** +        14+ ***** +14        + ***
*** +        15+ ***** +15        + ***

Friday, November 09, 2007

Windows Server 2008 - Windows SharePoint Services 3.0 Dropped

Over on the Windows Server Division WebLog, there's an article entitled Windows Server 2008 and Windows SharePoint Services 3.0 Update. Despite the innocuous headline, the contents reveals that Windows SharePoint is being dropped as an 'in the box' component. I find this very disappointing. But to quote Jeffrey Snover, "to ship is to choose" and I guess WSS is not ready for release yet and so has been dropped.

The claim that MS dropped this feature "to allow customers to most conveniently obtain the technology" as suggested on the blog seems somewhat wide of the mark. The most convenient way is to include the technology in the box (ala PowerShell), not make users find some web site somewhere. Presumably WSS 3.0 was just not ready.

PowerShell V2 New Feature - Out-Gridview

Out-GridView is new cmdlet in PowerShell V2 CTP. The cmdlet takes the output of the pipeline and opens a new window to present the data. This windows is a simple grid, with Columns that can be sorted.

For example,

get-process |select name,handlecount,vm,pm |out-gridview

This simple statement gets the processes, removes all but a few properties, and pipes that to out-grid-view. This creates a separate window, like this:

 

Some neat things - first each of the column headings can be clicked to re-sort the output based on that column. You can also type in some characters at the top to find a subset of the rows, like this, where I type "exp" and find all the processes whose name contains "exp":

This stuff rocks!!

PIC Licensing for OCS

I had an interesting comment on this blog recently based on an older blog article. The question was around the Public Internet Connectivity licenses and whether they were still available. I checked with some great folks in Redmond and got a pretty clear answer: PIC is still alive and is being sold. Rumours of its demise seem premature and/or in error.  Hope the helps.

My Redmond contact also pointed me to the Office Live Communications Server PIC page which should answer all the relevant questions.

Technorati tags: , ,

Windows PowerShell V2 Graphical Help File Available

The PowerShell V2 goodies keep on coming! Those nice Scripting Guys have not released the Windows PowerShell Graphical Help File (Version 2.0). This 2.6mb executable file is actually just a self extracting zip -  PowerShell2.chm.

This .chm is just the same info as in other PowerShell help files, just wrapped in a more friendly CHM wrapper. This CHM file is actually the same Windows PowerShell help file that you’ve come to know and love plus some addons. The Microsoft Scripting Guys wrapped the PowerShell help files into a more user-friendly (and fully-searchable) format and added some stuff. In the CHM you’ll find:

  • Windows PowerShell cmdlet help for all cmdlets.
  • Windows PowerShell “About” files (all of them)
  • The Script Center’s VBScript to Windows PowerShell Conversion Guide. Help for the VBS dudes converting into the light.
  • The Windows PowerShell Beginner’s Guide, featuring articles from the Script Center’s Windows PowerShell Owner’s Manual. A nice addon.
  • A complete collection of the Script Center’s PowerShell tips of the week. Great tips to play with and to help you to learn more.

Nice job!

Wednesday, November 07, 2007

More on PowerShell Background Jobs (PSJobs)

In a blog  post yesterday, I talked about the new background job feature in PowerShell Version 2 CTP. One thing I did not entirely appreciate till today (and it should be blindingly obvious), a PSJob produces objects just like any other cmdlet. That means if your the background script produces objects of any kind, the Receive-PSJob cmdlet can retrieve them for manipulation locally. As should be obvious the remoting feature of PowerShell V2 works the same way (you remote a script to a system and get back objects).

Here's a demo of this (with a lot of lines cut out for brevity!)

[ 0]PS D:\foo\v2 > #
[ 1]PS D:\foo\v2 > # Examine PowerShell V2 jobs feature
[ 2]PS D:\foo\v2 > # Demonstrates Start-PSJob, Get-PSJob, Wait-PSJob, Receive-PSJob
[ 3]PS D:\foo\v2 > #
[ 4]PS D:\foo\v2 > # start a job, see it is running,
[ 5]PS D:\foo\v2 > #
[ 6]PS D:\foo\v2 > $job = Start-PSJob "Get-Process" -Name "Job-2"
[ 7
]PS D:\foo\v2 > Get-PSJob

SessionId       Name            State           HasMoreData     Command
---------       ----            -----           -----------     -------
1               demo            Completed       True            get-process
9               Job-2           Running         True            Get-Process

[ 8]PS D:\foo\v2 > #
[ 9]PS D:\foo\v2 > #now wait for it to finish
[10]PS D:\foo\v2 > Wait-Psjob $job

SessionId       Name            State           HasMoreData     Command
---------       ----            -----           -----------     -------
9               Job-2           Completed       True            Get-Process

[11]PS D:\foo\v2 > #
[12]PS D:\foo\v2 > # now get output
[13]PS D:\foo\v2 > #
[14]PS D:\foo\v2 > $procs=receive-PSJob $job -keep
[15]PS D:\foo\v2 > $procs

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
    240       8    74584      54684   230 1,077.59   4888 AcroRd32
    116       5     1220       1480    32     1.14   3092 alg
     43       2     1320        852    29   700.95   3828 ApntEx
     93       3     1744       1816    37 2,261.53   3960 Apoint

{ And a whole lot of lines snipped for brevity}

[16]PS D:\foo\v2 > #
[17]PS D:\foo\v2 > # look familiar?
[18]PS D:\foo\v2 > #
[19]PS D:\foo\v2 > $procs | gm

   TypeName: Deserialized.System.Diagnostics.Process

Name                       MemberType     Definition
----                       ----------     ----------
Handles                    AliasProperty  Handles = Handlecount
Name                       AliasProperty  Name = ProcessName

{ And a whole lot more lines also snipped for brevity}

[20]PS D:\foo\v2 > #
[21]PS D:\foo\v2 > # so...
[22]PS D:\foo\v2 > #
[23]PS D:\foo\v2 > $procs | sort handles -desc | select -first 5 |ft name, handles, wm,ws,priorityclass -auto

Name          Handles wm       WS PriorityClass
----          ------- --       -- -------------
svchost          9125    30830592 Normal
OUTLOOK          5444    55250944 Normal
searchindexer    1685    43831296 Normal
explorer         1306    43503616 Normal
csrss            1289     6451200 Normal

 

This is really pretty cool!! You get the PSjobs to run and collect objects and then analyze them locally/remotely. There are some things missing from this CTP, like no NEW-PSJOB, and the input to Receive-PSJob is a job object, not the job-object's id. This means Get-Psjob 9 would return the job noted in the above example, but Receive-PSJob 9 does not (yet)  work.

Another point - the objects returned are de-serialized objects, thus you only get their properties - there is no direct way I can see to return the methods (although I'm sure someone will figure it out). So while you can stop or start a process using the objects returned from get-process, the deserialised objects returned from PS job don't have those methods to call. I'm not sure if this is a good thing or not . But I'd bet that rehydrating live objects across a network is non-trivial!

 

But it's still a great start! 

Tuesday, November 06, 2007

Background Jobs in PowerShell V2

PowerShell v 2.0 introduces the concept of a background job. Implemented as a PsJob, a job runs a command or expression asynchronously and "in the background" without interacting with the console. Jobs are started by the Start-PSJob command. You can run these background jobs on a local or remote computer.You can check he status of the job by using Get-PSJob (or by getting the job and using the job's JobStateInfo property). 

The PSJob features rely on the new remoting features of PowerShell V2, which is one reason why you have to load WinRM prior to installing PowerShell V2.

Here is a demonstration of the background jobs feature. I've taken a leaf from Jeffrey Snover's book and have used his demo-script and have created txt files with the demos. Here's my starting job demo:

 

<Demo [job-1.txt] Started>
 
[0]PS D:\foo\v2 > #
[1]PS D:\foo\v2 > # Examine  PowerShell V2 jobs feature
[2]PS D:\foo\v2 > # demonstrates start-psjob, get-psjob, receive-psjob, remove-psjob
[3]PS D:\foo\v2 > #
[4]PS D:\foo\v2 > # create a job
[5]PS D:\foo\v2 > $job = start-psjob "get-process" -name demo
 
[6]PS D:\foo\v2 > #
[7]PS D:\foo\v2 > # get all jobs on the system
[8]PS D:\foo\v2 > # notice the sessionid they are all odd
[9]PS D:\foo\v2 > # our job is at the end of the list
[10]PS D:\foo\v2 > get-psjob
 
SessionId       Name            State           HasMoreData     Command
---------       ----            -----           -----------     -------
1                               Completed       True            get-process
3               demo            Completed       True            get-process
5               demo            Completed       False           get-process
7               demo            Completed       True            get-process
9               demo            Completed       True            get-process
11              demo            Completed       True            get-process
23              demo            Completed       True            get-process
25              demo            Completed       True            get-process
29              demo            Completed       True            get-process
31              demo            Running         True            get-process
 
[11]PS D:\foo\v2 > #the job's state field (not well named)
[12]PS D:\foo\v2 > $job.jobstateinfo
 
                                                      State Reason
                                                      ----- ------
                                                    Running
 
[13]PS D:\foo\v2 > #
[14]PS D:\foo\v2 > #
[15]PS D:\foo\v2 > # Look at out job - hopefully it's finished running
[16]PS D:\foo\v2 > $Job
 
SessionId       Name            State           HasMoreData     Command
---------       ----            -----           -----------     -------
31              demo            Completed       True            get-process
 
 
 
[17]PS D:\foo\v2 > # Now go and get the job output
[18]PS D:\foo\v2 > receive-psjob $Job
 
Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
    240       8    74584      54476   230   619.81   4888 AcroRd32
    116       5     1220       1480    32     1.03   3092 alg
     43       2     1320        852    29   562.53   3828 ApntEx
     93       3     1744       1816    37 1,875.88   3960 Apoint
    282       9     8876      11748    70   367.50   4356 Connect
   1267      10    15420       7120    64   655.44   1592 csrss
     74       4     1288       1776    30    10.30   2308 ctfmon
    140       6     4900       1572   178     7.03    252 EvtEng
    683      10    10500       5092   148     3.28   6104 EXCEL
    969      26   142368     116180   294 4,901.31   3328 explorer
    779      25   460976     405548   736 ...68.50   2788 firefox
    502      13     9320      14888   120   354.69   4832 FrameworkService
    115       4     2724       1796    36     1.08   1564 ftp95pro
     75       2      596        820    19     0.81   1300 GhostStartService
    249       7     3948        612    59     2.56   2612 GoogleToolbarNotifier
     53       2     1676        980    22     5.53   3796 hidfind
      0       0        0         28     0               0 Idle
    842      24    37884      19536   178 1,225.72   2900 iexplore
    134       4     1896       2216    43     3.70   1144 IFXSPMGT
    111       3     2452       1436    36     1.78   1484 IFXTCS
    486      21     7112       5432    67   577.66   1512 inetinfo
    736      16    10336       4056    56   160.22   1672 lsass
     91       4     1720       4760    37     0.16   2016 McScript_InUse
    374     100    39488      45000   128   507.33   4012 Mcshield
     35       2     1040       3368    27     0.19   5600 Mctray
    120       3     1448       2092    34    49.97    232 MDM
    297       8    19524      16180    66   592.89   5608 MsMpEng
   1040      42    56544      35100   244 2,413.48   3632 msnmsgr
    154       6     5836       1064    58   367.59   4436 naPrdMgr
    115       4     3792       1760    42     2.20   4144 notepad
     54       3     1452        996    31     0.42   5236 notepad
     50       3     1404       1560    32     1.58   5588 notepad
    327       3     2352       2812    25    69.28    576 nvsvc32
   5173      74   145860     111148   548 1,435.66   4432 OUTLOOK
    566       5    11428      15408    54    10.64   1132 PKTray
    692      13    13456       3728   176    93.25   1044 POWERPNT
    346      10    28428       2028   171     2.16   2716 powershell
     21       1     172        132     4     0.48   1476 smss
{ more output snippped!}
 
 
 
[19]PS D:\foo\v2 > #
[20]PS D:\foo\v2 > #look at list of jobs
[21]PS D:\foo\v2 > get-psjob
 
SessionId       Name            State           HasMoreData     Command
---------       ----            -----           -----------     -------
1                               Completed       True            get-process
3               demo            Completed       True            get-process
5               demo            Completed       False           get-process
7               demo            Completed       True            get-process
9               demo            Completed       True            get-process
11              demo            Completed       True            get-process
23              demo            Completed       True            get-process
25              demo            Completed       True            get-process
29              demo            Completed       True            get-process
31              demo            Completed       False           get-process
 
 
 

 

 
[22]PS D:\foo\v2 > # remove our job from the list
[23]PS D:\foo\v2 > remove-psjob $job
 
 
 
[24]PS D:\foo\v2 > # see it's gone
[25]PS D:\foo\v2 > get-psjob
 
SessionId       Name            State           HasMoreData     Command
---------       ----            -----           -----------     -------
1                               Completed       True            get-process
3               demo            Completed       True            get-process
5               demo            Completed       False           get-process
7               demo            Completed       True            get-process
9               demo            Completed       True            get-process
11              demo            Completed       True            get-process
23              demo            Completed       True            get-process
25              demo            Completed       True            get-process
29              demo            Completed       True            get-process


PowerShell V2 - New Features!!

There's a bunch of new features in PowerShell V2 - although some will change and some of the things in the CTP may even  be dropped. That's the nature of CTPs! A good place to start is to read the release notes that describe the new features and show worked examples.

Here's my list of key new stuff in PowerShell V2:

  • Remoting - PowerShell now includes support for executing cmdlets and scripts on remote systems using WinRM. COOL!!!!
  • Background jobs - PowerShell V2 now has the concept of background jobs that you can spawn and monitor.
  • Script Cmdlets to enable you to write rich cmdlets in PowerShell. In PowerShell V1, you could write functions that sort of felt like cmdlets. With V2, you can now write fully fledged cmdlets using just script which is very cool!!!
  • Stepable pipelines - a neat feature to enable you to  control the execution of the pipeline.
  • Data Language - provides for better separation of scripts and data. Useful for internationalisation scenarios
  • Script debugging - there are improvements to debugging. Hooray
  • New operators and new internal variables - some new operators and new system variables have been added
  • New Cmdlets - the range of standard cmdlets has been expanded with 24 new cmdlets, including Out-GridView, Invoke-WMIMethod and Start-PSjob.
  • Additional APIs - as ever, more APIs for devs to play with.
  • A very early alpha release of a more GUI like PowerShell shell. A nice concept

This is a very nice set of improvement, and goes a long way towards making PowerShell the only choice for command line admin under Windows!

Along with the rest of the PowerShell bloggers, I'll be looking at these new features in upcoming blog articles. The next year or so (the lead up to the RTM) is going to be fun!!!

Sadly, there seems no improvement to the documentation of trap and throw. :-(

Windows PowerShell 2.0 CTP - Available for Download

The Version 2 CTP build of PowerShell is now available for download. See: Download details: Windows PowerShell 2.0 CTP for the downloads.

There are some release notes there too - these are good reading. And while I realise most folks will not want to RTFM, this time it's pretty useful. And there's a draft SDK. The documentation is really very good!

So get downloading!!!!

Saturday, November 03, 2007

Windows PowerShell V2 CTP Shipping Soon

VERY COOL -- V2 PowerShell CTP is shipping to the web very shortly. There are some incredibly neat components of V2. Some are aimed at ISVs and more advanced users. There are also some darn useful other stuff that I really am enjoying too. I have it running here and it's very stable. I'll let Kenneth and the PowerShell team spill the details, but this is a very useful update. PowerShell V2 ROCKS!!

As an aside, this CTP represents the PowerShell team's efforts, a year after V1 was released. A lot of neat technology but some unfinished work too. Of course this is to be expected, but it means that this release comes with a warning clearly spelt out on the PowerShell team's blog: CTP != BETA !. I expect many things will change  between now and RTM (whenever that happens).

One interesting aspect of the CTP and PowerShell V2, it's a replacement for PowerShell V1, and not a side-by-side install. So far as I can tell, everything I can do in V1 (in terms of demos in classes, etc) works just with the CTP. Well so far!!   This also means that .ps1 files run with PowerShell Version 2. This could get confusing. Well it could have had the team not thought ahead. As Jeffrey Snover describes in a blog entry (Versioning), you can code around this. Just begin your scripts with a #Requires directive! For example:

#REQUIRES -Version 2
"In script that requires PowerShell Version 2"
If you run this on a system which does not have V2 yet (like most of you reading this now!) will get a message:
PSH [D:\foo]: .\v2.ps1
The script 'v2.ps1' cannot be run because it contained a "#requires" statement at line 1 for Windows PowerShell version
 2.0. This does not match the currently running PowerShell Version 1.0.
At line:1 char:9
+ .\v2.ps1 <<<<

Now that shows someone really thought ahead - a very nice touch. And I so much want to say a lot more about this release!

In closing, a CTP health warning as requested:

The PowerShell V2 CTP is not for everyone. You should read this PowerShell Team blog entry ( http://blogs.msdn.com/powershell/archive/2007/11/02/ctp-watch-this-space.aspx ) to find out what it is and what it isn't and then make an informed decision before installing the CTP. 

Thursday, November 01, 2007

WikipediaVision (beta)

 This is an interesting mashup - basically the WikipediaVision page displays a Google map of the world and shows where updates are coming from, in near real time. A fascinating view of how Wikipedia is being updated - you quickly realise just how much global updating is going on - totally fascinating.

Technorati tags: , ,

DNS Expert and Book Author Cricket Liu To Present Designing a resilient DNS/DHCP Network

 Now this is cool - one of  my all time net-god heroes, Cricket Liu, is in town (London) to present a seminar entitled Designing a resilient DNS/DHCP Network. A chance to hear Cricket speak - you bet I'll be there.

Technorati tags: , , ,

Learning Plans for OCS 2007

Over in my corporate blog, I jotted down some links to information that helps you learn more about OCS 2007. Take a look at my Learning Plan for OCS 2007 - and please provide comments.

 

Sunday, October 28, 2007

OCS 2007 Inter-Operating with Nortel CS 1000

In researching the OCS Learning Plan I  found a neat web cast you can download from Microsoft web site.  The main starting page for this  webcast is on the MS TechNet site. This page requires you to log in with a MS Passport, which takes you to the live meting site from where you can pick up the webcast. A little long winded process wise, but a good webcast!  In addition to the 8mb WMV file, you can also download just the PowerPoint slides (14.2MB ), or just an mp3 podcast.

This is, for me most useful as it shows how to do this interop and explains many aspects of the Nortel products, including more details on the ICA solution. I am looking forward to working more with the Nortel and the ICA tools in some upcoming work.

Technorati tags: , ,

Saturday, October 27, 2007

PowerShell Remoting through Group Policy

Special Operations software has just announced SpecOps Command: PowerShell Remoting through Group Policy. I was lucky enough to see a neat demo last week while in Stockholm - this is a neat tool. As I understand it, it'll be formally released at TechEd in Barcelona.

 Basically, SpecOps uses group policy to send out scripts, cmdlets and (I assume providers) to client systems. These scripts are then run on the target machine (one, daily, weekly, etc) and the results returned back to a central server. A very very neat solution to the lack of remoting in PowerShell V1. And even when we get V2 (a preview edition of V2 will be available in Barcelona), GP may be a better option due to permissions on the local systems.

I can't wait to get my hands on this code! Yet another aspect of the power of the PowerShell community - when there are gaps, someone or some organisation will just fill them. PowerShell rocks - and so does SpecOps Command.

Sunday, October 21, 2007

Communicator 2007 Hotfix Package

 Microsoft has released a hot fix for Office Communicator 2007.

As noted in the KB article (Description of the Communicator 2007 hotfix package: October 5, 2007), this hot fix package includes at least 15 separate bug fixes.

This is probably a must-add hot fix for OCS 2007 users.

Technorati tags: ,

Saturday, October 20, 2007

PowerShell Training In Europe

As noted in over in my work blog, I'm starting to teach PowerShell in Europe. My first classes are this week in Stockholm and in Copenhagen. I'm delivering the two day PowerShell Fundamentals class in both cities. To say the least, I'm really excited to finally being able to run real PowerShell training for our customers.

In the background, Microsoft has engaged a vendor to create a formal MOC class on PowerShell, but we'll not see this till next June. In the mean time, if you want PowerShell training in Europe, feel free to contact me and I'll put you in touch with the local office. And wherever possible, I'm happy to come to teach these classes.

Thursday, October 18, 2007

Office Communications Server 2007 Document: Technical Reference

 Microsoft has at last published the detailed technical reference to OCS 2007. This is a must read for all OCS fans!

Download details: Office Communications Server 2007 Document: Technical Reference

Monday, October 15, 2007

Vista Adoption Numbers

 One of the big questions many commentators are posing is just how much deployment is happening with Vista. Forget the MS statements around adoption - what is really happening. From where I sit, adoption is not as rosy as MS would want us to belive - and like many I'm no longer using Vista on front line systems as I've gone back to XP.  Over on the Hackers blog, Alex reports Random: Some Vista adoption numbers. These show that Vista is in use by only 10% of their web site users, and less than1% of the users of CounterSpy. These numbers feel a little bit lower than the MS VIsta Hype Machine would lead us to believe.

What is your take on adoption - what are you seeing??

Technorati tags: , ,

Sunday, October 14, 2007

Updated Live Writer

Microsoft's Windows Live Writer blogging tool has now reached Beta 3 stage. As a free blogging too, I find it excellent - and now even better. The latest release, which you can download from Microsoft's webs site.

There are many improvements in Beta 3. These include:

  • Publish XHTML-style markup

  • Use Writer in 28 additional languages

  • Print your posts

  • Justify-align a post's text

  • Better image handling (in particular fewer blurry images)

  • Resolved installation issues from the last release

  • Plus Many other bug fixes and enhancements

 

Get it now!

[LATER]

Unfortunately, as one reader has pointed out in a comment to this blog entry, it appears that the latest beta of Live Writer does not work on x64 systems which is a pretty significant omission. Thanks to Chris Randall for pointing this out - I missed it since I am still mainly using i386 systems.

 

Friday, October 12, 2007

First-Gen Zune Getting All The New Features: This is How You Treat Your Customers

Gizmodo is reporting that First-Gen Zunes Are To Get All The New Zune 2 features (for free!!). The post goes on to suggest that "This is How You Treat Your Customers". I agree completely!! Having ordered the Zune two days before the announcement, it was a shock to find that whilst in transit, my purchase was not outdated. It was a delight to find the extra features will be available for free download. In effect, I've got a somewhat smaller and marginally thicker box, but for what I use it for (short-ish commutes up to town and flights inside EMEA) my 30gb model is fine.

So thanks Microsoft - this is really the way to treat your customers. The folks over in the Vista group (and MSL) could learn a thing or two from this very nice move.

Technorati tags: , ,

PowerGUI - A updated version is available

Those nice folks at Quest have released a new version of PowerGui - this is a free download you get  here: http://powergui.org/filedownload.jspa?attachmentID=915&filePath=/shares/powergui/sbin/downloads/PowerGUI.1.0.11.207.msi.

NB: if you have an earlier version of PowerGui, this must be removed before installing the new version.

This is a neat tool!!

Technorati tags: , ,