Friday, November 09, 2007

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: , ,