Saturday, June 30, 2012

Playing with Windows 2012 Multi-Computer Configuration options

I’m doing some editing of an upcoming course on Windows Server 2012. One key feature of the course is showing off multi-computer management. As part of that, I’ve rebuilt a pair of Windows 2010 RC servers. I plan to run VMs on both machines, but also to manage the pair using PowerShell and the new Server Management tool. The new Server Manger now resembles this screenshot taken from one of my new hyper-V hosts:

 

image

As you can see, I’ve defined two new server groups, HyperV Guests and HyperV Hosts. This tool makes it possible to mange groups of servers as a single entity. Under the hood, things get really cool. When you carry out remote management using Server Manager, Server Manager creates a PowerShell Workflow to carry out the management task, and then executes it against the remote  servers. But I can also do this directly from PowerShell (with our without the workflow aspect).

For example, suppose I want to add all the RSAT tools to both HyperV hosts: Well I could do it from the GUI, but from PowerShell, this is trivial:

Invoke-Command –ScriptBlock {Get-WindowsFeature –Name *rsat* | Add-WindowsFeature} –Computer Cookham11,Cookham12

And just like that, all the RSAT tools got loaded on both machines. This is extremely powerful but to really make use of it, you have to start thinking a bit differently and get to know and love PowerShell remoting.

Technorati Tags: ,

Wednesday, May 02, 2012

Another Fine PowerShell PowerCamp Weekend–Sadly All Over!

The weekend of April 21/22, 18 hearty IT Pros and I spend two days looking into PowerShell. A jump start look at all the key aspects of Windows PowerShell. The event focused on the core aspects of PowerShell – Cmdlets, the Pipeline, Objects, and Remoting. We we also reviewed the the PowerShell language as well as the cmdlets that have been added into Windows Server 2008 R2/Win8.

The attendees came from all walks of (IT Pro!) life, but all shared an interest in really learning more about PowerShell. The event only lasts 2 days and there is an obvious limit of how much anyone can absorb without brain overload creeping in. A key focus of all the modules was discovery – how the attendees can figure out stuff for themselves, and leveraging the community. 

It was a great weekend and I still have some admin to do around it. I am currently looking into a further PowerCamp in the autumn – during October if possible.

And a big thanks to Idera, MVP Systems and Quest – all of whom kindly provided some goodies I could provide to the delegates. Much appreciated.

Technorati Tags: ,

Thursday, April 26, 2012

Lync for Macintosh–update released

Microsoft has released an update for the Lync client for Mac. This update fixes the following:

  • Several issues with Cisco and Juniper VPN clients
  • An issue that causes an Active Directory lockout when the Kerberos protocol is used
  • Several issues that cause Lync for Mac 2011 to sign out unexpectedly or to crash

Microsoft recommendl all Lync users on Mac install the update. You can find more information at: http://support.microsoft.com/kb/2690036:

Monday, April 16, 2012

PowerShell Weekend PowerCamp–Coming very soon

As many of you know, I’ve long been an advocate of all IT Pros (and devs!) learning more about PowerShell. There are a lot of ways to do this, and one great way is to attend a short (read 2 day at the weekend), jump start events. And as it happens, there’s one coming up soon.

This weekend coming, April 21-22, I’m holding the latest PowerShell PowerCamp, a weekend PowerShell jumpstart training event. We’re holding the event at Microsoft’s London offices in Cardinal Place Victoria from 9:00 till 5:00 – two long days of PowerShell, PowerShell, and more PowerShell.

The details of the agenda remain as I first published them back in January. There’s still a couple of places should you fancy the opportunity to learn more about PowerShell, so if you fancy it, let me know by emailing DoctorDNS@Gmail.Com and I’ll take it from there.

Technorati Tags: ,

Sunday, April 08, 2012

PowerShell Scripting Games–Halfway Complete!

If you are a PowerShell Junkie, you know that the PowerShell Scripting Games began last Monday, and the first five events, in each category, are now posted and are being judged. If you are not a PowerShell junkie, the PowerShell Scripting Games is an annual competition amongst beginner and expert scripters to show off their scripting skills (or to learn more!). I described this in my blog last week (http://tfl09.blogspot.co.uk/2012/04/2010-powershell-scripting-games-begins.html). For a more light-hearted introduction, see Sean’s We Will Script It:

 

We Will Script IT!

The Scripting Games are a time for YOU to both show off your skills, and to lean more. For the judges, it’s turned into quite a lot of work, and a learning opportunity too!

The number of entries, so far, way exceeds my expectations. As of today, here is the count of entries:

image

If you are good at counting, or can use PowerShell to do the maths – this is tallies to just under 1500 scripts entered so far – and we’re only half way through the overall event. WOW!  I certainly did not expect anywhere near so many entries!!! This just goes to show the momentum and traction that PowerShell is getting.  But it’s sure ended up being a lot of work for the judges – having to review every script and mark it. I had hoped that this year, I’d be able to rate every script, but so far, I’m way behind – I’ve rated probably not much more than 500 so far, and given my real life job, may get further behind as the week goes on! What a really nice problem to have.  I may not end up rating ALL the scripts, but I’ll do my best.

In judging the entries so far, there are several things I’ve noticed:

  1. Some folks can’t read very well or type well. Sad smile There have been far too many scripts entered for the wrong event - if you are entering Beginner Event 1, then please don’t submit the script for Advanced Event 1 or any other event! Also, some folks are not reading the specific details that the script is meant to deal with. While some of the solutions are great, they are not ones that meet the criteria of the event(s).
  2. Handling of Boolean values is not well understood. If you have a Boolean value in PowerShell (eg $Foo), then checking true/false in an If statement should look like this:

       If ($Foo) { <action if true>} else {<action if false>}

    and NOT this:
  3.     If ($Foo – eq “true”) { <action if true>} else {<action if false>}

    Strictly speaking, testing $foo against ‘True’, $true (and $false) works, but the explicit test is unnecessary. And if you are testing against a false value, $foo –eq “false” returns false, NOT TRUE!  I intend to cover boolean values more in the upcoming PowerCamp!

  4. Live vs Static Objects – some objects, when created, are filled with property values that never change (until you refresh the objects). Other objects do update some properties but this is not universal. The System.Diagnostics.Process class is one that a) does some automatic refreshing of property values and b) has a .Refresh() method that refreshes the value. Calling .Refresh is a little faster than creating the whole object. And hands up – I did not know about the .Refresh() method  prior to this year’s competition!
  5. Comment, comment, comment. I see lots of script without any comments, either in the script or in the comments on the solution. If you make a mistake with syntax, the comments might save you a point!
  6. There are a lot of new folks out there who have got the message (PowerShell is the future) and are going great guns to prove their skills. Thanks for your time and effort and even though the scores may not show it – you’re all winners!!

And while thinking about it – see Ed Wilson’s comments on the Games so far at: http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/07/six-observations-about-2012-scripting-games-early-entries.aspx.

So far, this has been a pretty cool competition, and it’s taught me a few things already. If you have not yet joined in, there’s always time to do a few entries. And remember, it’s taking part that counts, not whether you win or lose – everyone’s a winner here!!

And finally – if you are looking at the Events, wondering a) how to solve them and b) feeling like you SHOULD know(!!), and you live in the UK, consider coming along to the PowerShell PowerCamp weekend – we’ll be covering some if not all of the event scenarios during the weekend so who knows, attendance at PowerCamp could mean you are next year’s winner.

Monday, April 02, 2012

2012 PowerShell Scripting Games Begins Today!

As many PowerShell fans know, today sees the beginning of Microsoft's PowerShell Scripting Games. The Scripting Games are a set of 10 PowerShell challenges in two classes (Beginner and Expert). The idea is simple: you sign up for either of the classes and each day for 10 days you get a scripting challenge involving writing a PowerShell Script. After solving the challenge and writing your script, you submit it to Poshcode.Org. Once submitted, a stellar panel of judges review it and each script gets up to 5 points. At the end of the Games, the folks with the highest scores win prizes. Easy!

Each individual event is to be posted at noon Seattle time (i.e. 20:00 here in the UK). So consider this a bit of homework! Once posted, you have 7 days to submit an answer. Once submitted, your script gets judged by the distinguished panel of judges based upon a set of judging criteria. You should read these criteria as they can affect the score your submissions receive.

To see all the links for the Games, visit here. This has pointers to how to register, details of the judges, and everything you need to know about the games. For each contest, you’ll also get a Guest Commentary from someone in the PowerShell community looing at how they would go about solving the problem. Speaking for myself, I look forward to reading both the scripts entered by the competitors AND to the guest commentaries. I am sure to learn something – it happens every year!!

So if you think you have good PowerShell skills, or if you just want to learn more – come on down, enter and enjoy the contest!

Technorati Tags: ,

Wednesday, March 21, 2012

Finding The Folder the .NET Utilities Live in - Using PowerShell

I am playing around with some PowerShell V3 stuff and needed to use Ngen.exe to do a native generation of an assembly and move it to the Global Assembly Cache. So where is it? I could have wandered around in the Windows folder, but instead decided to ask .NET itself, using PowerShell.

The .NET class System.Runtime.InteropServices.RuntimeEnvironment contains several static methods that return information about the CLR environment.  There are three that are of possible interest to the IT Pro:

FromGlobalAccessCache – this static method tests an assembly to determine if it ewas loaded from the GAC.

GetRuntimeDirectory – this static method returns the folder name where the CLR was installed. This folder contains Ngen, the C# complier, and other .NET tools.

GetSystemVersion – this method returns the version number of the .NET Framework

 

From PowerShell Version 2, this looks like:

 

image

If you are using the beta version of PowerShell V3, you might see this:

image

File under: Interesting things you can do with .NET and PowerShell.

Wednesday, March 07, 2012

PowerShell Version 3–Updatable Help (continued)

In a recent blog article I discussed the new updatable help feature of PowerShell V3. In that post I described the Update-Help cmdlet and shows how you use that cmdlet to up date your help information. The Update-Help cmdlet knows how to go online to find, download and install updated help information for both the core PowerShell modules plus any additional modules on your system. The PowerShell V3 module feature enables Get-Help to know (or be told!) where to look for updated material for each module, and does what is needed!

But what if you are offline, or you are in an air-gap network, isolated from the Internet. Well, obviously, in that situation, Update-Help can not go online and get the necessary updates. But PowerShell does provide a cmdlet, Save-Help, that can get the necessary help information and can store it. You can then copy somewhere Update-Help can then find – in the case of an airgap network, you could copy the help information to a memory stick, then use sneaker-ware to copy that material onto the airgap network.  Let’s take a look at both these aspects.

To save the help files, you use Save-Help, specifying a destination path (where you want the files saved). Optionally, you can specify the UI culture for which you want to get updated help. Specifying the –Verbose switch provides more output describing what Save-Help is doing. By default, you can run Save-Help or Update-Help just once per day (per machine). To over ride this, use the –force parameter.

Here’s what Save-Help looks like in my Windows 7 workstation:

 

SNAGHTML1f74f896

As you can see from this screenshot, PowerShell gets the files and stores them in the path folder, which then looks like this:

SNAGHTML1f79c392

Each PowerShell module has the two files that make up the extensible help for that module:

  • An XML file – this identifies the UI version of the help content (found in the XML).
  • A cab file – containing updated MAML and about_* files. Each file in the cab file represents something to be moved (later) by update help.

Each pair of files is named using a simple naming convention of : <module name>_<module guid>_<ui culture>_<helpinfotype, where <helpinfotype> is either HelpContent (in which case the file has a .CAB extension), or HelpInfo (in which case the file has a .XML extension).

You will notice that when I got the help, Save-Help could not find help for the module TFL. That’s mainly because that help information has not yet been written and saved in EN-US locale (well, not yet anyway!). I will do another blog post at some point where I explain how to add updatable help to your module.

To install this help on the air-gap network or machine, or one you want to update offline, you first have to save the files to somewhere you can later access them from the network/machine. As I suggest above, a USB memory stick can be used to transport them (or CD, etc). Once you have the files moved to their appropriate place, you use Update-Help, specifying the SourcePath parameter and providing the path to where the help files are available. The update would look something like this:

SNAGHTML1f8d8193

The Update-Help cmdlet (when verbose is specified), displays the XML files parsed and whether or not the associated HelpInfo file was processed and the help files in the CAB file that have been moved to their appropriate location.

 

Technorati Tags: ,,

Pluralsight Course–Formatting with PowerShell

I’ve just finished creating my latest course for Pluralsight, entitled Formatting with PowerShell. The course looks at how you can get great output from PowerShell  - including both defaults and what you can do to improve your output.

Formatting, to my mind, is the art and science of presenting data to your target audience. Great looking output not only is easier to read and consume, but it often gives (possibly unearned) credibility!  PowerShell does a lot of things by default, making it the superior tool for the IT Pro. This course shows you how you can get the most out of what PowerShell provides by default, but also what you can do to over ride these defaults.

The course has 6 modules:

Module 1 – Introducing .ToString(). The core of PowerShell (and .NET) formatting is the .ToString() method. I regard the .ToString() method as the basis for all formatting in PowerShell, so it’s important to understand this .NET feature. The module looks as using .ToString to format numbers, dates, time spans and enums.

Module 2 – Composite Format Strings. This is a feature, leveraged from within .NET that I use a lot. We look at what makes up a composite format string and how to use the –f operator to format strings.

Module 3 – Formatting In the Pipeline. This module looks at how you can use the Format-* commands to format objects coming from the pipeline.

Module 4 – Using Hash Tables. Hash tables can be used to improve the output, particularly output generated by Format-Table and Format-List. We look at these hash tables and provide examples as to how they work.

Module 5 – Format Files and Display XML. Default formatting in PowerShell is based on format files and display XML. This module looks at how you can write your own format files, both to change default output and to create new views for your own, or existing, data types.

Module 6 – Other Output Mechanisms. This final module looks at the other ways you can data out of PowerShell, including using the Out-* cmdlets, CSV and CliXML for persisting objects and both HTML and Office document output.

Each module has demos, best practices and provides a great summary. The course material includes the slides and all the demos which you get depending on what level of Pluralsight membership you have.

The course is finished and is going through the production phase which shouldn’t take too long – I expect the course to be on the web site this week. I have to say, the guys at Pluralsight are pretty good not only about making sure the course is high quality, but that all the bits are where you want them! I’m impressed overall with their people and their process. They make me want to write more material for them!

And a call out to TechSmith (www.techsmith.com). The course is recorded using Techsmith’s Camtasia and the screen shots captured using Techsmith’s SnagIt product. I could not have recorded this course without these two great products. If you are developing presentation or training course material, you should be looking at these two products. Once you have them, you’ll fall in love with them!  Thanks TechSmith!!

Sunday, March 04, 2012

Invoking a PowerShell Command from within a program–How Do They DO That?

One of the aspects of the Monad Manifesto was its advocating building GUIs on top of PowerShell. For some devs and fewer IT Pros, the mechanism is pretty clear and straightforward. But for a lot, it’s a bit of a black art. In this article, I’ll look at how they do that, but I’ll demostrate by doing it in PowerShell (with a pointer to seeing it in C#).

Running PowerShell within your executable program (irrespective of it being a GUI or a console application), involves 3 objects:

  • Runspace – a runspace is the operating environment pipelines. A pipeline runs within a runspace.
  • Pipeline – a pipeline is used to invoke commands.
  • Command – a cmdlet or script that gets added to a pipeline to run in a run space

Each of these three objects are found within the System.Management.Automation.RunSpaces namespace and are pretty easy to create and manage. The descriptions of these objects in MSDN are a little thin in and could usefully be improved with more examples.

Here’s a script that illustrates this (analysis is below the script)

###
#   Create a PowerShell runspace and open it
$rs = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
$rs.open()

#   Create a Pipeline
$Pipeline= $rs.CreatePipeline()

#   Create a command and add parameters
$cmd = New-Object system.management.automation.runspaces.command "Get-Process"
$cmd.Parameters.Add("Name", "Power*")

#   Add the first command to the Pipeline
$Pipeline.Commands.Add($cmd)

#   Invoke the pipeline
$collection = $pipeline.invoke()

#   See what's there
$collection
###

So what does this script do? Well first, it uses the runspace factory ( a feature built into .NET)  to create a new runspace on the local machine. Once created, the script opens the runspace for use.

Next we use the runspace object to create a new pipeline. We create a new  command object using New-Object. The command object is meant to run the  Get-Process  cmdlet and has a parameter (-Name) which for this run will have a value of ‘Power*’). 

After the command is added to the pipeline, the pipeline is invoked. Invoking the pipelines involves PowerShell, in effect, to run the Get-Process cmdlet with the appropriate parameters and return a result. That result, which is the same as you get running the command locally, is an array of objects that match the globbed name parameter (i.e. it would match PowerShell, PowerShell_ISE, PowerPoint, etc).

If you want the pipeline to have more than one command, that’s easy too. Suppose you wanted to support the output we obtained above? In other words, suppose you want to get the effect of “Get-Process –Name Power* | Sort-Object –Property CPU”? That’s easy. Just before invoking the pipeline above, just add the following:

#    Create a second command and add parameters
$cmd2 = new-object system.management.automation.runspaces.command "Sort-Object"
$cmd2.Parameters.Add("Property", "CPU")

#    Add the second command to the Pipeline
$pipeline.Commands.Add($cmd2)

It’s actually pretty easy, if you understand how to manage the three key objects involved. If you think about it, the sequence the script goes through is pretty much what PowerShell itself is doing when you are sitting at the console. The console is a little more complex, but most of the real magic is in the runspace itself and that is something the script and developers in general just leverage the feature.

An interesting aspect here is that all three objects are created using different approaches. The runspace is created by a static method on the runspace factory class, the pipeline was obtained by calling the runspace object’s method, CreatePipeline, and the command object(s) are created using New-Object.

So where might this be useful to an IT Pro. Probably not a lot of direct use – since PowerShell is doing all this for you (i.e. creating the run space, managing the pipeline and pipeline commands within, and marshal the output from the execution into something sensible at the console).  But I hope this might be of assistance to developers that are getting into PowerShell for the first time and want to integrate it into their applications.

Friday, March 02, 2012

PowerShell Version 3 Updatable Help Content

PowerShell has always had good in-box help. Each cmdlet has extensive documentation, complete with syntax and parameter details and plenty of good examples. As with all documentation, updating the help content has not been easy – or as easy as you might imagine.

With the decision to move PowerShell inside Windows, the help text has become almost read-only. If you think about the relative importance of changing help text post release, updates are not critical, so they don’t go out as part of the monthly update cycle. They don’t meet the bar for a Service Pack either. The bottom line for V2 in-box help text is that it’s effectively frozen till Win8 ships. The PowerShell team have partly worked around this by updating the on-line help, and giving the Get-Help cmdlet the ability to display, nearly seamlessly, the on-line help (i.e. use the –Online parameter to Get-Help).

For Version 3, PowerShell has updateable help content. To update your help text, you just type Update-Help and the cmdlet goes on-line and pulls down help not only for the core PowerShell cmdlets, but also for any module you have loaded on your system! That’s really cool!! This ships today with the new Version 3 update for earlier OSs and the new Win8 client/server beta.

As with many great features, there come some provisos and gotcha:

  • Help content is not installed by default. When you implement the MSU to add PowerShell 3 CTP to your older system or when you load Windows 8, there is only a bare skeleton of help information available. Much of this tells you to update your help. This decision is not going to change – you have to run Update-Help to update help. Microsoft may, I understand, consider doing some things via say Group Policy, but that’s not been confirmed.
  • UI Locale matters to Update-Help. Update-Help will look for help contents in the same language as your current locale. This is a problem for the Win8 beta since the number of languages supported by the beta is limited. I want en-GB content, based on my current locale, but there is none. There is, en-us, so I must specify explicitly the UI culture of the help I want to download.
  • You need admin rights to run Update-Help successfully. So use an elevated PowerShell prompt.
  • You need Internet access to get to the help information. You can, however, get the help content from the internet, place it somewhere, then use the –SourcePath or the –LIteralPath parameters to tell Update-Help where to find the Help source information.
  • Update-Help provides minimal output by default. Use the –Verbose parameter to Update-Help to see more of what’s going on.
  • Update-Help limits usage to once a day. By default, you cant’ update help more than once per day. This is to minimise the load on the MS servers providing this information. You and force Update-Help to run by specifing the –Force parameter to Update-Help.

WIth all this said here’s what Update-Help looks like on my system:

Before…

image

Updating Help:

image

And after…

image

In summary. PowerShell has updatable help and will use it moving forward. There are some small tricks to making it work for you, especially during the Win8 beta phase. But it’s a great feature and I love it already.

Thursday, March 01, 2012

PowerShell V3 Beta now available for down-level Operating Systems

Unless you’re in a cave deep in the moutains somewhere (in which case you won’t read this anyway!), you know that Microsoft has now released the first beta of Windows 8 client and server. Personally, I downloaded the server beta yesterday and am busy playing with it. Over the weekend, I will load it native on my laptop (brave man that I am).

One of the key features for me of both the server and client editions is the new beta of PowerShell V3. Microsoft has also poduced versions of the PowerShell beta for Vista/Server 2008 and Windows 7/Server 2008 R2. These contain all the same builtin cmdlets as you get with WIndows 8, without the addons only contained in WIndows 8. I am using this build now on my main workstations that are not yet running Windows 8.

You can get these beta builds at http://www.microsoft.com/download/en/details.aspx?id=28998. Note there are separate builds for the 2 OS sets and for 32 vs 64 bit systems. Be careful over which version you download.  And read the release notes carefully (when MS publishes them).

So far this new build continues the excellent work done in the past and is rock solid for me, albeit with a few areas where I think there’s more work that needs doing. Performance, for example, in a few places is not what it should be. And the debate over how help should be added into to box continues (I’ll document this issue in a blog post tomorrow). This all bodes very well for V3 being a great addition to the family!

So if you are using an older OS, consider downloading and using the latest PowerShell update. If nothing else, the new ISE is so good, it’s really worth it. Naturally, exercise due caution as this is a beta, etc. Having said that, it’s an excellent next step that I’ve put on all my key machines.

Wednesday, February 29, 2012

PowerShell, the ETS and Type XML

One of (the many!) cool features of PowerShell is the ETS, the Extensible Type System. With the ETS, you are able to create new types and, perhaps more importantly, extend existing types simply and easily.  The ETS is one of the key ways that PowerShell provides a level of consistency in the objects you use, despite that consistency being lacking in the underlying object(s).

Take, for example the System.Array type. This type, in .NET, has a Length property, but does not have a Count property. Why not, I hear you ask. The answer is simple: the folks that developed this type did not include it. Sadly, the .NET Framework has lots of little (potential) inconsistencies. In a perfect world, we can fix this – and with PowerShell we can!

Using a bit of XML, you can easily add an alias called Count to the Name property. This XML looks like this:

<Types>
    <Type>
        <Name>System.Array</Name>
        <Members>
            <AliasProperty>
                <Name>Count</Name>
                <ReferencedMemberName>Length</ReferencedMemberName>
            </AliasProperty>
        </Members>
    </Type>
</Types>

To add this alias, you just save this XML (say to My.Types.PS1XML) then import this definition into PowerShell by using the Update-Type cmdlet. Now as it happens you don’t need to do this for System.Array, as Microsoft has already provided this extension (and a bunch more) in $PSHome/Types.PS1XML, which is loaded by default. But I think you get the idea.

If you want to see the ETS at work, take some time to study this Types.PS1XML file – it shows  how PowerShell extends .NET specifically to provide a level of consistency across objects that is missing from the .NET Framework itself. Some cool things this file does include:

  • Provides .ToString() methods for a number of types (these definitions override the default .ToString() method in the type itself.
  • Add new properties implemented as PowerShell script blocks. For example, System.Management.Automation.PSDrive is extended with a script property called Used (but for PSdrive objects that are based on the FileSystem provider only!). 
  • Define default Property Sets for some objects. These then become the properties that PowerShell display by default. For example, the default property set for System.ServiceProcess.ServiceController is defined as; Status, Name and DisplayName. If you run the Get-Service cmdlet, you will see these three properties are displayed by default.

The ETS enables you to adapt ANY .NET type – adding in properties that don’t exist, or overriding the ones that do exist. These new properties can be a new alias (as noted above), a script property, or a script method. One particular place I’ve found recently where this is useful is on the output of Get-ADComputer. If you run Get-ADComputer (Part of the active directory module shipped by Microsoft with Server 2008 R2), the output is objects of the type Microsoft.ActiveDirectory.Management.ADComputer. This type has a Name property for the computer name (which is the host name) as well as a DNSHostName. This is all fine and well, but many of the cmdlets that take a computer name (and send the command to that computer for processing) use the ComputerName property. So how do you use Get-ADComputer to get computer names and then pipe the output to other cmdlets when the property names differ?  For example, suppose you want to find  One way is like this:

Get-ADComputer –filter * | foreach {Get-Service –name ‘DNS Server’ –computername $_.name} …

That’s a bit messy – as we wanted the computer name to be returned from Get-ADComputer and used in the call to Get-Service. By default, this is not possible. However, if we do some magic type adaptation, we could add an alias property to the ServiceController object, like this:

<Types>
<Type>
    <Name>Microsoft.ActiveDirectory.Management.ADComputer</Name>
    <Members>
          <AliasProperty>
                <Name>ComputerName</Name>
                <ReferencedMemberName>Name</ReferencedMemberName>
            </AliasProperty>           
    </Members>
</Type>
</Types>

Once you import this definition (use Update-TypeData specifying the filename including this definition), then, we can do this:

Get-AdComputer -Filter * |
   
Get-Service -Name "DNS Server" -ErrorAction SilentlyContinue |
        Format-Table MachineName, Displayname, Status –Autosize

On my system, this produces the following output:

MachineName DisplayName  Status
----------- -----------  ------
COOKHAM1    DNS Server  Running
TALLGUY2    DNS Server  Running

As you can see, Type XML is the key to exploiting the ETS. With Type XML and the ETS, POwershell and you can find consistency in places where it’s never existed. What a cool feature!

[Later]

Thanks for the comment from JB. If, like JB,  you were wondering why I a using the MachineName property in the call to Format Table. The ComputernName property is initially created on the objects produced by Get-ADComputer. The Get-Service cmdlet takes the objets from the pipeline and gets the ComputerName property the sends the service request to the computer named by computer name. However, Get-Service produces objects that return the ComputerName in a Machinename property (even though the CMDLET parameter is Computername)!  Rather demonstrating my point about consistent inconsistency! I could add another alias property to the ServiceController type, which is not a bad idea!

 

Technorati Tags: ,,

Wednesday, February 08, 2012

Get-ChildItem and the–Include and –Filter parameters

I saw a good question the other day in the PowerShell.Com Learn PowerShell Forum which related to using –Include when calling Get-ChildItem (or DIR, or LS!). The OP had a bunch of files in a folder (C:\Data) and wanted to get at just the *.txt files as follows:

Get-ChildItem –Path C:\Data –Include *.Txt

But it did not work – it returned no files at all (even though there were some in the folder. The reason is clear if you read the great help text closely: the Include switch is only active if you are also using the –Recurse parameter! Another small to make is that the –include property specifies a globbed string (I.e. a file name specified with Wild cards) and not a regular expression.

The simplest way to just get the text files form a single folder would be:

Get-ChildItem –Path C:\Data\*.Txt

Another way to get just the Text files in a given folder would be to use the –Filter parameter. The –Filter parameter  is sent to the provider and is used to qualify the –Path value. You can call it like:

Get-ChildItem –Path C:\Data\ –Filter *.Txt

So you have two ways to get a subset of files in a folder using a form of early filtering. And if you use –Recurse (thus are getting all the files in a folder and it’s child folders), you can use either the –Include or –Filter parameters. They give the same result. Well almost. If you use –Include *.txt, you only get the files which have an extension of .txt. Using  -Filter, you get a slightly different result as shown here:

Psh[Cookham8:C:\foo]>Get-ChildItem -path c:\DATA  -filter *.txt -recurse  -ea Silentlycontinue
    Directory: C:\DATA
Mode                LastWriteTime     Length Name                                                        
----                -------------     ------ ----                                      
-a---          2/5/2012   3:48 PM          0 copy.txtfoo                                                        
-a---          2/5/2012   3:48 PM          0 one.txt
-a---          2/5/2012   3:48 PM          0 three.txt
-a---          2/5/2012   3:48 PM          0 two.txt

As you can see, *.txt also copies *.txtfoo. I’m sure this is ‘by design’ but it doesn’t seem to map to my expectations. Still, in most cases, extensions do not overlap like this (of course PowerShell is an exception – with .PS1 and .PS1XML extenstions!).

As an alternative to using either –Filter or –Include, you could always get ALL the child items (e.g. all the file and folder objects in C:\Data), and pipe the output to Where-Object for further (later) filtering. This works, but as most IT admins know, early filtering tends to be more efficient. But the filtering done by –Filter may be surprising – If I use –Filter *.ps1, then PowerShell returns me all the PowerShell scripts in

The –Filter parameter also turns out to have an additional benefit. The value of Filter you specify is used by the provider to qualify the path value. By comparison, the –Include specifies a filter for PowerShell to apply. Thus, the –Filter parameter generates early, early filtering, whereas-Include is later early filtering! The performance difference between the two approaches turns out to be significant! I wrote a little script to calculate the costs of using the three methods, as follows:

# Test-Filtering.PS1
$start = get-date
$f = Get-ChildItem -path c:\windows  -include *ps1 -recurse -ea Silentlycontinue
$end = Get-Date
$time1=$end-$start
"Using -Include    : {0,4} files in {1,-6:n2} seconds" -f $f.count,$time1.totalseconds
$f| ft name,length

$start = get-date
$f=Get-ChildItem -path c:\windows  -filter *ps1 -recurse  -ea Silentlycontinue
$end = Get-Date
$time2=$end-$start
"Using -Filter     : {0,4} files in {1,-6:n2} seconds" -f $f.count,$time2.totalseconds
$f | ft name,length

$start = get-date
$f=Get-ChildItem -path c:\windows  -recurse  -ea Silentlycontinue | where {$_.extension -eq '.ps1'}
$end = Get-Date
$time3=$end-$start
"Using Where clause: {0,4} files in {1,-6:n2} seconds" -f $f.count,$time3.totalseconds

The results are here:

image

I have to say, the numbers were not what I was expecting! I was surprised how much faster –Filter turned out to be – around 3 times quicker than either –Include, or using late filtering. And compared to using –Include, late filtering is really not all that much slower.

 


Wednesday, February 01, 2012

Windows PowerShell PowerCamp–Helsinki March 10-11

Arrangements for this event in Helsinki are moving along nicely. Those very nice people at Sovelto, who are hosting the event, have put up a new web page around the event: see http://www.sovelto.fi/kurssit/Pages/PowerShell-PowerCamp.aspx (or to see this page in Finnish, go to : http://www.sovelto.fi/Kurssit/Kurssivalikoima/Pages/Kurssihaku.aspx?kurssiID=3647). These web pages have the Helsinki agenda and all the details of where/how to book, etc.

As you will see, the event is over the weekend of March 10 and 11 2010 at Sovelto’s offices in Helsinki. We’ll start at 9 both days. We will be including lunch, refreshments and breakfast both days, with a nice meal out and a bit of fun for the Saturday night (details will be announced soon – it should be fun!).

So if you are anywhere in the world and want to get a first class jump start to PowerShell, consider coming! We’ll even have PCs for all the attendees as well as a nice little goodie basket to take home!

Contact me if you have any questions – or better yet, contact Sovelto and book a place!

Monday, January 23, 2012

PowerShell PowerCamp Weekend–London–April 21-22 2012

As I noted in an earlier bog post,  I
’m pleased to be able to bring you a PowerShell PowerCamp weekend events in London in the not too distant future.  Here’s the details!

 

What is A PowerShell PowerCamp?
This fast paced weekend event covers all the key aspects of Windows PowerShell - from the command line and writing production-oriented scripts. We start with the basics including installation and configuration, formatting and providers and remoting. We then look at scripting, managing script libraries using modules, using objects, and finishing with the PowerShell features added into Windows. We finish with a look at PowerShell in the cloud and what’s coming with PowerShell V3.


The PowerCamp event is all lecture plus Q&A, with the opportunity to type along with the tutor. There are no formal labs.

What is the Agenda?
Day 1 – The Basics
• PowerShell Fundamentals – starting with the key elements of PowerShell (Cmdlets, Objects and the Pipeline) plus installation, setup, and profiles
• Discovery – finding your way and learning how to discover more
• Formatting – how to format output nicely – both by default and using hash tables and display XML
• Remoting – working with remote systems using PowerShell’s remoting capabilities
• Providers – getting into OS data stores via PSProviders
Day 2 – Diving Deeper
• Scripting Concepts – automating everyday tasks including PowerShell’s language constructs, error handling and debugging (both from the command line and using an IDE)
• Modules – managing PowerShell script libraries in the enterprise
• .NET/WMI/COM Objects – working with native objects
• PowerShell and Windows Client/Server – how you can use built in PowerShell cmdlets
• PowerShell in Key Microsoft Servers - a look at PowerShell today in SQL, SCVMM plus a look forward to the future with SharePoint 2010
• PowerShell and the cloud – this module looks at PowerShell in the cloud and how you can use PowerShell to manage cloud computing.
• PowerShell V3 – this final module shows you what’s new in PowerShell V3.

What does it cost?
The cost is £200 (+VAT at the prevailing rate) for the weekend. Meals and accommodation are not covered.

Where is the event going to take place?
The PowerShell PowerCamp is being held at Microsoft Cardinal Place, 100 Victoria Street in Victoria on the weekend of April 21-22 2012. Each day starts promptly at 09:00 and finishes up by 16:45.

PowerDrinks?
After Saturday’s session, attendees are invited to a small nearby public house for some lovely English ale.

Who is the tutor?
The PowerShell Weekend PowerCamp is delivered by Thomas Lee. Thomas is a veteran PowerShell MVP who has been involved in the PowerShell community since the very beginning. He provides training and consultancy around a range of Microsoft products, with a recent focus on PowerShell and Lync Server. Thomas runs PowerShell training courses around the world, and has been a speaker at conferences across the world for the past decade. In his spare time, he lives with his wife, daughter, wine cellar, and Grateful Dead live recordings archive in a small cottage in the English countryside. His Twitter handle is DoctorDNS and he maintains two blogs (Under the Stairs at http://tfl09.blogspot.com and PowerShell Scripts Blog at http://pshscripts.blogspot.com).

What do I need to bring
You need to bring a laptop PowerShell loaded. We suggest you have at least two VMs pre-configured (i.e. a Server 2008 R2 domain controller and a member server). And if you have access to the Windows 8 beta, bring along a Win8 VM for the look at PowerShell V3. The virtualisation software is not of concern – but you need 64-bit guest OS support. Thus you can use Hyper-V, VMware Workstation or Oracle’s Virtual Box.

How do I book?
Contact DoctorDNS@Gmail.com to book a place and to arrange for the invoice to be paid. Payment must be in cash, cheque or bank transfer – I don’t take credit cards.

More Details
Watch Thomas’s blog for any hot breaking news on the event.

 

Two New PowerShell PowerCamp Events Coming Soon

I’m pleased to be able to bring you two more PowerShell PowerCamp weekend events in the upcoming months:

  • HELSINKI – Weekend of March 10-11 2012 – takes place in the offices of Sovelto, at Ratapihantie 11 (1st floor) in Helsinki. I do not have pricing or this event yet but will post details as soon as I get them. We will have something interesting for Saturday night to be included in the price.
  • LONDON – Weekend of 21-22 April 2012 – takes place at Microsoft’s Cardinal Place offices in London Victoria. We’ll all repair off to a local hostelry on the Saturday evening for a beer or three.

I’ll post more details about each event soon.

 

Friday, December 16, 2011

Lync 2010 Lync Mobile Client

Earlier this week, I blogged about the new Lync mobile client – i.e. client software for smart phones and the iPad. As of mid afternoon today, the client sets for WP7 and Android are shipping. From the comments I hear from users – this software is fairly trivial to install and does what it says! It also adds value to the Office 365 proposition. I can’t wait to use it against Lync Online!

There is one small gotcha – in order to use this new client against your on-premise Lync deployment – well first you have to have one (the client is of no use unless you have an implementation of Lync to use it against). And secondly, assuming you have Lync working, there are upgrades to the product, the mobility service, that need to be added. And there are a couple of DNS changes to be made and a new firewall port to open. Those are pretty straightforward but of course have to be done before the client can work against your implementation of Lync.  For those of you on Office 365, all that work is done – although you need to make DNS changes if you are hosting the DNS for your Office 365 domain.

I’ve seen very few issues reported so far, and the general consensus in Twitter at least is that the client is working well. About the only negative comment was from Michael Smith (Market Management Director at Cisco). Of course he got it wrong ranting about no Android/IOS support, which seemed to blunt most of his argument. One point he does pick up on is  that there is no VOIP feature in the client.

To support VOIP, the mobile handset would have to either support wireless and have wireless connectivity or use the cellular data channel against your data plan. Those are the only two ways to get the IP datagrams carrying VOIP signaling and data from your phone to the other end of the connection. If you are using wireless to connect, then VOIP calls will constitute additional bandwidth both from the phone to the WAP and from the WAP into your enterprise network. If your wireless infrastructure is not up the mark, you end up with poor service and a bunch of unhappy users. Using your cellular carrier for the actual phone call reduces that risk.  If you were using VOIP over wireless, then the battery life takes a hit.  Battery life on my phone is sure improved when I turn the WIFI off!

Using VOIP over the cellular carrier’s data channel might have once made sense – sadly the days of unlimited data may well be gone with most mobile phone companies imposing limits and costs. And don’t get me started about how expensive it can be to use data roaming when outside the UK or worse outside the EU (around half my working time is spent outside the UK). Even with the inflated call cost outside the UK, using the mobile network for the phone calls is a lot cheaper. Outside the EU, we can pay over £6/mb for cellular data. A one minute call over such a link would consume in the region of 4.6mb (assuming RTA Narrowband is used) for the call and would cost around £14.00. Worst case rates on O2 are £1.79/minute for the cellular call. A no brainer to me – plus the company pays the cost of the call.

A VOIP client in the product might have been nice to have, but from an Enterprise perspective, using Call-From-Work makes more sense as provides better assurance over call quality and lower help desk calls. These users do, of course,have Skype which works perfectly as a VOIP phone for those times when they can tether on the USB to keep the battery topped up and are on a well provisioned wireless network. With Skype now belonging to Microsoft, I can’t help but thinking that one day we will have the combined client – but exactly what Skype will do to Lync is a topic for another day. 

But in the meantime, it looks like another nice addition to the Lync family aimed at.  I am anxious to try it out!

Technorati Tags: ,,

Tuesday, December 13, 2011

PowerShell ISE Script Explorer–Get it Today

Microsoft has just released the latest CTP release of the Microsoft Script Explorer for Windows PowerShell. This is an add-in to the ISE that enables you to search for scripts within the PowerShell ISE. With this release, you can:

  • Search online repositories including PoshCode and Technet
  • Establish and search local and corporate script repositories
  • Filter search by location and product relevance
  • Browse Community Resources, including the TechNet Wiki
  • Integrate community samples into corporate script library seamlessly

This CTP is based on an invitation – and I just happen to have one:

https://connect.microsoft.com/site1064/InvitationUse.aspx?ProgramID=7431&InvitationID=TL10-GX2K-3VFW

Click on this link and login to Connect. If you are not already resistered on Connect, you need to sign with a valid Microsoft LiveID.

So head on over, and try it out. Feel free to leave you comments – either here, or with Microsoft!

Technorati Tags: ,

PowerShell’s ++ and -- Operators (Redux)

A couple of days ago, I posted an article on PowerShell’s ++ and – operators. I grew up using programming languages that never implemented the auto increment/decrement operators, this was a neat new feature for me.

But I have had a couple of comments pointing out that these operators are not new, are in C# and what I describe is indeed by design. Of course they are right. The point I was making was aimed at those new to PowerShell and who probably do not have a background in programming.

For the avoidance in doubt, I know how these operators work and am well aware of them and their behavior. Smile But I do see many IT Pros that discover these operators for the first time in a PowerShell class – and it was a question I’d been asked that I posted about.  For those new to programming and to PowerShell, these two operators are a neat find and I advocate using them. But like many of PowerShell’s richer features, you have to know how they work.

 

Microsoft Begins Shipping the Lync Mobile Client

For those of us in the Lync world, the release of a Lync client for mobile phones has been long awaited. Although Microsoft released Lync 2010 to the market over a year ago, there has been no mobile client up till now. The lack of a mobile client has been a point some Microsoft competitors have been quick to jump on. But starting earlier this week, the client is slowly rolling out on 5 key platforms (Windows phone, iPhone, iPad, Android and Nokia Symbian).  Thus far, Microsoft has only released Lync for the Windows Phone – the others are shown as ‘coming soon’ on the Mobile Clients for Microsoft Lync web page.

Microsoft cites 4 key features of the new Lync mobile client:

  • Join conferences with a single touch - no access code or pin number is required.
  • Stay connected, while controlling your availability – you can see who's available at a glance and connect over IM, email or a call. You can also set your own status and notification settings so you can stay in touch while protecting your "off-work" time.
  • Communicate with others using a single, consistent identity. The Call-via-work feature allows outbound calls using your Enterprise Voice number, making it easier for others to recognize calls from the Lync mobile client.
  • Connect with confidence through channel encryption, transport layer security (TLS) support, and perimeter/internal network protection that help safeguard your communications.

To the dismay of some, there is no VOIP client – all phone calls to/from the device have to be made over the cellular network, but Call from work and One Number reach do make that a little less expensive.  It appears that the Call via Work feature will not be shipped with Android.

Like so many things Microsoft, the client is not something you can just load from the relevant store and have it work – you do need some work on your Lync implementation and need to install the latest cumulative updates (CU4 in particular) to get the necessary services up and running that support the motile client.

These requirements are spelt out in yet another TechNet article: http://technet.microsoft.com/en-us/library/hh690988.aspx. You will need to do some work against your DNS servers to ensure automatic discovery and sign-in works properly. Although this is pretty straightforward, it is work that needs to be planned for and carried out. If you are an Office 365 user and Microsoft is managing your DNS, the work appears to be already done. I host DNS externally to Office 365 but it took me just a few minutes to adjust my DNS settings as needed. You also have to install and configure the mobility service (in CU4), and update your voice policy to support use of the mobile client.

One important gotcha that might be easy to overlook: You need to include certain (new and additional) SAN entries on your key servers. In particular you need to adjust SAN entries on the certificates in your Director pool, your Front End Pool and the reverse proxy. If you use public certificates for any of these systems, you may have to buy an updated certificate for the RP system. 

In closing, it’s worth noting that the mobile client does NOT provide 100% of the features of the Lync desktop client.  You can see a good comparison of the various clients at: http://technet.microsoft.com/en-us/library/hh691004.aspx. Some features that are NOT provided by the mobile client (as documented in TechNet) include:

  • Caching multiple users account information on the same device
  • Modify Contacts List
  • Tag contacts for status change alerts
  • Control privacy relationships
  • Log IM conversations in Exchange/Outlook
  • Use dial-in audio conferencing
  • Transfer a call
  • Call a response group
  • Support E911
  • Client side IM archiving and client side recording

I can’t wait to get my hands on the client and to use it against my Office 365 account (tfl@reskit.onmicrosoft.com). From all I’ve heard from those who have the client – it does what it says it does and thus far appears stable and resilient. I look forward to using the client - As an iPhone user, I will have to patient. After all – I’ve been waiting 14 months or so for this client a few more days wait is not the end of the world! It will make a nice Christmas present!

Monday, December 12, 2011

Using PowerShell’s ++ (and–-) operator–Take Care

I got a great question the other week in a PowerShell class regarding the ++ operator. The delegated to know if there was any difference between $variable++ and ++$variable. In PowerShell, the operator ++ says, effect to add one to the variable it’s attached to.  So specifying $loopcounter++ as a statement on it’s own (e.g. inside a loop would just add one to the loop counter variable. 

I don’t use the ++ operator a lot – When I was first learning programming, the languages we had (assembler, Cobol, RPG, Fortran and Algol) never had these operators. So incrementing loop counters freestanding is about all I ever do. But I started playing and found some interesting things about ++!

First, looking at my most common use case, $variable++ and ++$variable seem to be the same as this code illustrates:

$lc=0;1..10 | foreach {$lc++};"Loop counter: $lc"
$lc=0;1..10 | foreach {++$lc};"Loop counter: $lc"

produces

Loop counter: 10
Loop counter: 10

 

So at that level the formats are equivalent in function.  And for the most part, the ++ operator used before or after the variable name produces similar results. But not in all cases. Consider the following code fragment:

“Case 1”;$lc=0;1..5 | foreach {"{0}" -f $lc++};"Loop counter: $lc"
”Case 2”;$lc=0;1..5 | foreach {"{0}" -f ++$lc};"Loop counter: $lc"

These two code fragments do not produce the same output. In the first case, the value of LC is formatted into the string, THEN it’s incremented, whereas in the later case, the incrementing occurs before the formatting. Thus the output looks like this:

Case 1
0
1
2
3
4
Loop counter: 5
Case 2
1
2
3
4
5
Loop counter: 5

So as you can see ++$variable is not always the same as $variable++.  Another curiosity of PowerShell that you just have to know!

[Later]

Of course, if you know C# or some other newer languages ++/-- may be old hat to you. And thanks for the comments that came from this post!

Wednesday, December 07, 2011

PowerShell 3.0 CTP2 Released for Windows 7/Server2008R2

I’ve been on the road a bit lately, and missed last week’s shipment of the PowerShell V3 CTP2. This is the second ''beta'’ of the upcoming PowerShell Version 3. At present this only works in Windows 7 and Server 2008 R2. There are, as I understand it, no plans for this to back-port to Vista and Server 2008 R2. I do hope that MSFT DO release a version for Vista and Server 2008 RTM but we’ll see.

In the meantime, the new version has lots of bug fixes, seems quite a bit faster and in general seems more mature than CTP1. In my case, the install was a bit confusing as I’m doing a multi-boot to VHD with Windows 8 on my laptop, unfortunately, one of the partitions (of course my default) ran out of disk space so after installing the update, recovering from the out of disk space issue, Win 7 thought the update had failed. I fixed the boot problem, then re-installed the update. From the looks of it, the update also does an in-place upgrade of the CTP 1 process (although the release notes ask you to remove CTP1 first).

The new CTP has a wealth of update to the console and the ISE. With the ISE, the output and input panes are merged into a single console like pane. Very useful and much easier to use. Read the release notes for a summary of what’s new.

You can get the various downloads that make up the release here: http://www.microsoft.com/download/en/details.aspx?id=27548. From that page you can get the 64-bit and 32-bit installation packages (.MSU files), release notes and a PDF containing a description of the new ISE Features and a description of the new features in Out-Gridview.

I love this product!

Technorati Tags:

Saturday, November 12, 2011

Using the PowerShell ISE–two cool finds

I’ve been using PowerShell’s Integrated Scripting Environment ever since it was in beta. Despite being relatively slow to load, it sure beats using Notepad for simple script development/debugging. The colour coding alone makes it even more useful! I love how you can add functionality to the editor via object model. It’s neat how that object model is exposed inside PowerShell as the $ISE variable – and how easy it is to use it to add menu items (and keyboard short cuts for the menu items).

A freely available module that offers a lot of ISE customisation is the IsePack, which is part of the PowerShellPack mega-module issued by Microsoft as part of the Windows 7 Resource Kit. You can download the full PowerShellPack from http://archive.msdn.microsoft.com/PowerShellPack. The PowerShellPack module is actually a set of 10 sub-modules. You can import the entire module (Import-Module PowerShellPack) or the sub-components. In my ISE Profile file, I add the ISE pack in specifically (Import-Module IsePack). That in turn exposes me an additional Add-On menu item, ISEPACK. This menu contains a set of sub-menus which add a lot of features to the ISE.

My two cool finds are partly what’s in IsePack and what I could easily add to it. The ISEPack creates a number of functions based on the ISE’s object model. It then leverages those in additional functions that PowerShell associates with menu items and keyboard shortcuts when the module is imported. And since the module is just a text file – you can easily edit it and add more features.

The first cool find is the Search-Bing function, which is associated with a menu item (Add-ons/IsePack/Search-Bing) and a keyboard shortcut (Ctrl-B). The Search-Bing function uses a lower level function,  Select-CurrentText, that gets the text that is currently selected somewhere on the ISE', then pipes it to copy of IE which points http://www.bing.com/search?q=$_. Thus, if I have the text ‘ToString’ highlighed in an open editor window, and hit Ctrl, I get a Bing Search Page, like this:

image

 

The second cool thing was how easy it was to ammend the IsePack module to add a Search-Google function. In the IsePack.PSM1 file, there’s a fragment of code that implements the Search-Bing feature (and adds it to the menu) This fragement is part of a larger script, but here’s the starting poing:

"Search-Bing" = {
        $Shell = New-Object -ComObject Shell.Application
        Select-CurrentText | Where-Object { $_ } | ForEach-Object {
            $shell.ShellExecute("
http://www.bing.com/search?q=$_")
        }
    } | Add-Member NoteProperty ShortcutKey "CTRL+B" –PassThru

 

As you can see, Search-Bing is associated with a script block that first opens the currently configured Web Browser (FireFox in my case). Then it executes a Bing Search on the currently selected text. This results in the search window coming up. So how hard was it to add to add a Search-Google? Trivial as it turns out. I just added the following text directly below the Search-Bing definition:

    "Search-Google" = {
        $Shell = New-Object -ComObject Shell.Application
        Select-CurrentText | Where-Object { $_ } | ForEach-Object {
            $shell.ShellExecute("http://www.Google.com/search?q=$_")
        }
    } | Add-Member NoteProperty ShortcutKey "CTRL+Shift+G" -PassThru

 

Sadly, Ctrl+G was already taken by something (a puzzle for another day!), so I used Ctrl+Shift+G and that brings up something like this:

image

 

As I am currently working on my next Pluralsight course on Formatting with PowerShell, I’m finding a need to look stuff up in MSDN and these two functions sure are useful to me!

Wednesday, November 09, 2011

PowerShell PowerCamp–A great weekend!!!

I’m now recovered from the most recent PowerShell PowerCamp – an intense two days of PowerShell training. I ran the event in London last weekend, and had 21 booked. Sadly there were two very last minute cancellations, so we we ended up with 19 eager souls. We walked through the basics of PowerShell at the command line on the Saturday, then on Sunday, started looking at scripting and other enterprise aspects of PowerShell. And on Sunday, we has Lync MVP superstar Tom Arbuthnot of Modality Systems in to talk some real world approaches to PowerShell.

On Saturday night we took over a small pub nearby, to the amusement of the locals, and continued chatting about PowerShell. I My lovely wife came up to London and we enjoyed a most interesting meal in Sobraine, a Russian restaurant in Victoria. Great food and very, um, interesting décor.

The delegates took home a memory stick with as many PowerShell goodies as I can find and will shortly be getting licenses for PowerGui professional and PowerShell Plus Pro, thanks to Quest and Idera!

I have no specific dates for the next PowerShell PowerCamp, but depending on interest, I would like to run another session sometime in the late spring (March/April). As ever, dates are tricky at that time of year what with half term and Easter, etc – but I’m sure we can find a good weekend should there be anyone wanting this level of training! And for those corporate readers – I’m happy to come to your place of work and run this same training for your team on your premises. If you have 6 or more delegates, this could be financially beneficial.

And in closing – a big thanks for Claire Smyth of Microsoft who was an enormous help in getting this event off the ground. Without her help and passion for the community, this event probably would not have happened! Thanks Claire!! And thanks too to Michael Sullivan for letting his hosting channel know about the event.

For any enquires about the next PowerCamp or running a PowerCamp privately, email me at DoctorDNS@Gmal.Com.

 

Technorati Tags: ,