Monthly Archive


Monthly Archives: October 2016

Don’t reinvent the wheel

Way back when I used to take Microsoft certification exams there were often questions of the form “Perform task X with the minimum of administrative effort” Most, if nor all, of the possible answers would be correct but the correct answer was the one that achieved the goal with the minimum amount of work.


Many, if not most, administrators don’t seem to follow that model.


This was brought home to me when I saw a forum discussion about collecting event log information from a bunch of remote servers on a regular basis.


You could set up a scheduled task/job that runs a script against the remote servers – collects the  log information and populates an Excel spreadsheet


You could enable event log forwarding and just interrogate the combined logs as needed.


The second option is the easier to MAINTAIN and will cost you less effort in the long run.


When you start to solve a problem – stop and search for a bit to see if there is a solution already available in Windows server. Bet you’ll be surprised by what you find

Start and end dates

Be careful with start and end dates when search for files or through event logs.  Often people want to see what happened yesterday

If you do this

PS> $end =  Get-Date
PS> $start = (Get-Date).AddDays(-1)
PS> $start

30 October 2016 16:32:35

PS> $end

31 October 2016 16:32:16

And you get the last 24 hours


if you really want just yesterday you need to create the exact dates and times

PS> $start = Get-Date -Day 30 -Month 10 -Year 2016 -Hour 00 -Minute 00 -Second 00
PS> $end = Get-Date -Day 31 -Month 10 -Year 2016 -Hour 00 -Minute 00 -Second 00
PS> $start

30 October 2016 00:00:00

PS> $end

31 October 2016 00:00:00


I know there are easier ways but using Get-Date shows exactly what’s happening and is simple

Registration opens 1 November

Registration for the 2017 PowerShell Summit opens tomorrow – 1 November 2016


First come first served. The agenda and registration are available here -

Upgrading WSL

If you start  WSL (Bash on Ubuntu on Windows) and see messages like this:


7 packages can be updated.
1 update is a security update.


You can view the available updates:

root@RSsurfacePro2:~# apt-get update
Hit:1 xenial InRelease
Get:2 xenial-updates InRelease [95.7 kB]
Get:3 xenial-security InRelease [94.5 kB]
Get:4 xenial-security/main amd64 Packages [160 kB]
Get:5 xenial-security/main Translation-en [65.8 kB]
Get:6 xenial-updates/main amd64 Packages [415 kB]
Get:7 xenial-security/universe amd64 Packages [51.9 kB]
Get:8 xenial-security/multiverse amd64 Packages [1,176 B]
Get:9 xenial-updates/main Translation-en [159 kB]
Get:10 xenial-updates/universe amd64 Packages [356 kB]
Get:11 xenial-updates/universe Translation-en [128 kB]
Get:12 xenial-updates/multiverse amd64 Packages [5,492 B]
Fetched 1,532 kB in 35s (42.9 kB/s)
Reading package lists... Done


And to install the updates use:

apt-get upgrade

PowerShell and DevOps Global Summit 2017 agenda

The agenda for next year's Summit is almost complete - we've notified all speakers as to whether their sessions have been accepted or not. If you haven't received your notification please check your spam/junk mail.


We have a small number of sessions yet to publish - mainly around possible focus groups on the Wednesday afternoon.


To view the agenda go to the Summit event site - from click on the Brochure and registration link.


Registration opens 1 November 2016.

PowerShell 10th Anniversary

If you were in the audience at the 2006 Microsoft European TechEd (or IT Forum or whatever they called it that year) key note presentation you’ll know that 14 November 2016 is the 10th anniversary of PowerShell.


The Powershell team is presenting a day long event on 14th November to commemorate the anniversary.


Initial announcement is here


More details to follow

PowerShell Summit 2017–agenda

We’re finalising the agenda for the 2017 Summit. Most of the sessions are now up on the event site. Go to and click the Brochure and Registration link. You’ll be able to down load a brochure describing next years Summit and view the proposed agenda (it is subject to change with no notice).

Registration opens 1 November 2016

Server Uptime

Its easy to get the last boot time of a Windows machine but how do you get the uptime


function Get-Uptime {
param (
   [string]$ComputerName = $env:COMPUTERNAME

$os = Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $ComputerName

$uptime = (Get-Date) - $os.LastBootUpTime




Use Get-CimInstance to get the Win32_OperatingSystem class. To calculate the uptime subtract the value of LastBootTime from the current time and date.

You’ll get a Timespan object returned.

PS> Get-Uptime

Days              : 1
Hours             : 10
Minutes           : 32
Seconds           : 26
Milliseconds      : 838
Ticks             : 1243468385381
TotalDays         : 1.4391995201169
TotalHours        : 34.5407884828056
TotalMinutes      : 2072.44730896833
TotalSeconds      : 124346.8385381
TotalMilliseconds : 124346838.5381


Pick out whichever properties you need for your report

Current location

Windows 10 gives you the option of installing BASH on Ubuntu - also known as the Windows Subsystem for Linux (WSL). More information from


I thought it would be interesting to compare some of the bash commands with their PowerShell equivalents.


First off – current location.

Its not obvious from the bash prompt where you are in the file system so you use pwd

root@RSsurfacePro2:~# pwd


In PowerShell you use Get-Location

PS> Get-Location



Interestingly you can use pwd in PowerShell

PS> pwd



That’s because pwd is an alias for Get-Location

PS> get-alias pwd | fl

DisplayName       : pwd -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location


If you want to discover all existing aliases for Get-Location

PS> get-alias | where ResolvedCommand -like 'get-location' | fl

DisplayName       : gl -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location


DisplayName       : pwd -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location


You’ll find that many core PowerShell cmdlets have aliases corresponding to Linux commands. Note that they are removed for PowerShell on Linux to avoid confusion.


Look out for other comparisons soon.

Easy and Expert

This is a very interesting article -

The premise that there is no “easy” button in IT is spot on and fits with this quote from  Theodore Roosevelt:

“Nothing in the world is worth having or worth doing unless it means effort, pain, difficulty…”  


IT is constantly changing – new technologies, new techniques, and new ways of looking at the problems.


The only way to survive is to keep learning. If you don’t you become part of the problem.


One of the comments castigating the author of the for declaring themselves a “newbie” given the work they’d put into learning DSC also caught my eye. When does someone move from being a newbie to becoming competent or even an expert?


Its as much in the mind of your audience as anything. I’ve been using PowerShell since the days of the version 1 beta code and have written and spoken more about the subject than I care to remember. Does that make me an expert? Many people seem to think so but as far as I’m concerned I’m still learning. So is everyone else that I consider an expert. To misquote

“Expertise is in the eye of the beholder”


When things change or you move onto something new the newbie clock gets reset so we’re all really newbies. Another way to think about it is that an expert is a newbie that has been working with the technology just that little bit longer.


Be wary of self proclaimed experts. The true experts tend to just get on with it.