Wednesday, July 31, 2019

The End Of My Era

For me, today is a sad day. At least in some ways. Today is the end of my career as a Microsoft Certified Trainer. My MCT  credentials lapse today and as I stopped taking/passing exams, I am no longer able to renew.  So this is the end of my 26+year road as an MCT and the end of my 51 year career in IT, largely focused on Microsoft technologies.

I first got excited about computers in 1968, when I found that the job of an operator paid something like $.50/hour more than washing dishes – and was way cleaner. After a degree from CMU in Computer Problem Solving (what the hip call AI today). I spent three years working both in tee US and the UK for Comshare. They were a time-sharing company and were, in effect, at the beginnings of the Cloud.

After several years as an OS developer, I took a sabbatical for 7 months. The high point of that trip was seeing Mt Everest over my shoulder from 18192 feet.


After returning, I joined Arthur Andersen and a few weeks later was in Chicago at a training event when I read about the launch of the PC and was blown away by the potential of the PC. Within days of the announcement, I was bugging our partners to invest. Looking back, I became one of the first DOS trainers in the world!  During the 1980s I taught to a variety of audiences on subjects including PCs, DOS, dBase, Word and Windows. I left Andersen in 1988 and launched my own company specialising in a combination of training and direct mail. in 1992 – One cool client was The Savoy Hotel Group which was a lot of fun.

I discovered NT (as an early beta tester) and began doing NT training in 1993 – teaching at SkyTech in London. Happy memories. I also taught for Learning Tree. Their NT and TCP/IP courses were awesome.  I then became an MCT at the very opening of the programme and until today I have remained an active MCT (MCT ID 6851).

Those early days were very different from today. To become an MCT you had to attend an evaluation session (often dubbed Shelia York’s Day Of Hell). I failed my first attempt – I was just told to turn up and was never given the relevant information. Second time around I nailed it and became both one of the first MCTs and one of the first MCSEs in the world.  You also had to attend a trainer prep course for any course you wanted to re-deliver – I taught a lot of these in my time which was a real honour to do this training.

I was also active first on MSN, then in the newsgroups, when there were newsgroups. I loved being able to help other MCTs. Like many MCTs, I  spent time working for Microsoft both in Redmond and Europe. As an MCT I served on a couple of advisory boards too. Perhaps the most meaningful for me was the Certified Learning Consultant initiative – requiring learning partners to have suitably qualified learning consultants on staff.

As many of the early MCTs will know, I have a passion for quality. Even when I all too often fall short myself. Such is life. When Lutz Ziob joined Microsoft Learning, he quickly outsourced much of the work that had previously been done internally (with LOTS of contractors – some of them awesome). The outsourcing made sense, unfortunately, the quality of what was produced was incredibly bad. I started a discussion about quality which I am glad to say had a major effect. One thing the discussion surfaced was that students often rated the courseware far better than the MCTs did. If nothing else, this proved the value of the MCT.

I have many happy memories: meeting Bill Gates and getting him to sign my Windows 95 Gold CD.


I also met Steve Ballmer on a couple of occasions. Here’s one:


In my travels, I have had many adventures, lost luggage, horrible rooms, cancelled/rerouted flights. I even spent an evening in jail in Turkey during a military revolution. I have also had the good times – flying Concorde, staying in the Savoy, and eating at the Tuna House. A precious memory was being in the room when Jeffrey Snover launched PowerShell and waving a $20 at him saying I’ll buy it.

So now it's over. I enter full retirement with a mixture of relief(I made it!) and sadness.







What a long strange trip it's been. Thanks for all the fish

Monday, July 22, 2019

Windows Forms - working in PowerShell 7 Preview2

One long-anticipated feature of what is soon to be PowerShell 7 is the use of Windows Forms. Technically, it is the .NET Framework that provides for form handling, but with the latest Preview.2 of PowerShell 7, this is now possible!

Here is a Windows Forms-based script that now works just fine in Powershell 7 Preview 2.

First, here is the code:

# Get-Shares Windows Forms Script
#

# Load System.Windows.Forms
Add-Type -Assembly System.Windows.Forms

# Get PowerShell version details
$Maj = $PSVersionTable.PSVersion.Major
$Min = $PSVersionTable.PSVersion.Minor
$Ver = "$Maj.$Min"

# Create form
$Form = New-Object Windows.Forms.Form 
$Form.Width = 750
$Form.Height = 650
$Form.Text = "My First Windows Forms Application - PowerShell Version $ver"

# Create a "computer name" label control and add it to the form
# Set label location, text, size, etc
$Label1 = New-Object Windows.Forms.Label
$Label1.Location = New-Object Drawing.Point 50, 50
$Label1.Text     = "Computer Name:"
$Label1.Visible  = $true
$Form.Controls.Add($Label1)

# Create a text box to get computer name and add to form
$Text1 = new-object windows.forms.textbox
$Text1.Location = New-Object system.drawing.point 150, 50
$Text1.Text     = "Localhost"
$Text1.Visible  = $true
$Form.Controls.add($text1)

# Create a label to output stuff
$Label2 = New-Object Windows.Forms.Label
$Label2.Location = New-Object Drawing.Point 50, 100
$Label2.Width    = 750
$Label2.Height   = 360
$Label2.Text     = ""
$Label2.Visible  = $true
$Form.Controls.Add($Label2)

# Create a button to get the shares
$Button1          = New-Object Windows.Forms.Button
$Button1.text     = "Push To Get Shares"
$Button1.width    = 150
$Button1.location = new-object drawing.point 350, 50

# Define Getting Shares Button Click handler
$Button1_OnClick = {
  $Label1.Text = "Getting Shares"
  $Shares = Get-CimInstance WIn32_Share -ComputerName $Text1.Text
  $Label2.Font = [System.Drawing.Font]::new('Courier New', 10)

  $Label2.Text = "Shares on $($Text1.Text):`n"
  Foreach ($Share in $Shares) {
    $Name = $Share.Name
    If ($Name.Length -gt 17) {
      $name = $($Name.substring(0,17)+'...').padright(16)
      }

    $Path = $share.Path
    $Label2.Text += "{0,-20}  {1}`n" -f $Name, $Path
  }
  $Label1.Text = "Computer Name:"
}
    
# Add the script block handler
$Button1.Add_Click($Button1_Onclick)    
$Form.Controls.Add($button1)

# Now create a button to close window
$Button2          = New-Object Windows.Forms.Button
$Button2.Text     = "Push To Close Form"
$Button2.Width    = 150
$Button2.Location = New-Object drawing.point 160, 550

# Define Button Click handler
$Button2_OnClick = {
  $Form.Close() 
}

# Add the script block handler
$Button2.Add_Click($Button2_Onclick)    
$Form.Controls.add($Button2)

# finally, show the form as dialog box.
$Form.ShowDialog()


And here you can see the results. First against first a work station:


And here a DC



Success. A working Windows.Forms script that runs great on Windows PowerShell now runs fine in PowerShell 7 Preview.2 (and beyond into infinity....)



Monday, July 01, 2019

Windows Terminal Is Here (in Preview) and it Rocks!

In Windows, PowerShell and CMD.Exe both run inside a console. That console is where programs interact with a command line application. The console inside Windows has not had a lot of love, although has improved of late. But that has just changed big time with the release of the Windows Terminal. If you are running Windows 10 - just go the Windows Store and get it - it's free.

The installation does a great job of detecting the console applications including CMD.EXE, PowerShell.Exe, PWSH.EXE, and the versions of WSL you are running, By default, the terminal installer does not find PowerShell 7.

Configuration of the WIndows terminal is, today, done via hand editing the Profiles.JSON file. On My workstation, this file is: C:\Users\tfl\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState\profiles.json - You may need to adjust it based on your userid.

To enable PowerShell 7,. I just added a new section at the top of the profiles section inside the profiles.json file. I added the following:

 {
   "acrylicOpacity": 0.75,
   "closeOnExit": true,
   "colorScheme": "Solarized Light",
   "commandline": "C:\\Program Files\\PowerShell\\7-preview\\pwsh.exe",
   "cursorColor": "#FFFFFF",
   "cursorShape": "bar",
   "fontFace": "Consolas",
   "fontSize": 12,
   "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff4442}",
   "historySize": 9001,
   "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
   "name": "Windows PowerShell 7.0.0 Core Preview",
   "padding": "5, 5, 5, 5",
   "snapOnInput": true,
   "startingDirectory": "%USERPROFILE%",
  "useAcrylic": false
  },

If you wish to add PowerShell 7, as I do, you need to do is to ensure the guid value inside this profile block is unique. You can just munge an existing GUID, as I did, or use New-Guid cmdllet create one know to be unique.

Since I plan to use Pwsh 7 mainly, I also wanted the default shell to default to using PowerShell 7. That also involves updating the Profiles.JSON file. At the top of the file, in the Globals section, change the value of the defaultProfile to the GUID of Pwsh 7. Mine looks like this


{
 "globals" : 
  {
   "alwaysShowTabs" : true,
   "defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff4442}",
   "initialCols" : 120,
   "initialRows" : 30,
 ... etc


Once I have set these values in the Profile.JSON file, my terminal looks like this:


And away we go. There is far more you can do with the JSON file and I sure hope that by release later this year, there is a GUI to help configure the settings. I don't mind in the least having to deal with the JSON file and can live with this for now.