Getting the most from your PowerShell Summit

With the first European PowerShell Summit rapidly approaching – 11 days and counting – I thought I’d give you a few ideas on how to get the maximum out of the Summit.

First – ask questions – lots of questions.  The speakers are masters of their topics and if you need to drill deeper to understand something talk to them in the breaks or over lunch. At Summits in North America we’ve had discussions go on well into the early morning!


Don’t try and copy code that you see.  The demo code and slides will be available after the Summit.


All of the sessions are recorded so you will have a chance to replay bits you need to see again. Some of the speakers will cram a lot into the sessions so accessing the recordings will be useful


Talk to your fellow attendees – I seen discussions where one persons problem was solved by another attendee who’d gone through the same issues


Make suggestions for topics you’d like covered at future Summits – if we get enough demand for a topic we’ll find a speaker


Representatives of the PowerShell will be present, and speaking. Talk to them. Tell them what you like. More importantly tell them what you don’t like or what isn’t working for you.  They love feed back from real users.


A number of PowerShell MVPs will be speaking or in the audience. This is your opportunity to talk to them and  ask your difficult questions. They are recognised experts and will be more than willing to help.


Lastly – ask questions. Lots of questions. If you can’t get your questions answered at a PowerShell Summit – there is a serious problem.

Multiple triggers on a scheduled task

Setting up a scheduled task can be accomplished like this:


$taskname = 'Test Job'

Get-ScheduledTask -TaskName $taskname -ErrorAction SilentlyContinue |  Unregister-ScheduledTask -Confirm:$false


$trigger = New-ScheduledTaskTrigger -Daily -At 03:00


$actionscript = '-NoExit -NonInteractive -NoProfile -WindowStyle Normal -NoLogo -Command "&{get-process}"'

$pstart =  "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

$action = New-ScheduledTaskAction -Execute $pstart -Argument $actionscript
Register-ScheduledTask -TaskName $taskname -Action $action -Trigger $trigger -RunLevel Highest -Description "Test job"


Define the task name and then unregister (remove) any instances of that task


You then define the trigger and actions and finally register the task with the name you defined earlier.


The script above will create a task to run at 3am.


You can force the task to run as a test:

Start-ScheduledTask -TaskName 'Test Job'


But what about if you want to run the task multiple times during the day. Simple.  You define multiple triggers:


$taskname = 'Test Job'

Get-ScheduledTask -TaskName $taskname -ErrorAction SilentlyContinue |  Unregister-ScheduledTask -Confirm:$false


$triggers = @()
$triggers += New-ScheduledTaskTrigger -Daily -At 03:00
$triggers += New-ScheduledTaskTrigger -Daily -At 09:00
$triggers += New-ScheduledTaskTrigger -Daily -At 15:00
$triggers += New-ScheduledTaskTrigger -Daily -At 21:00


$actionscript = '-NoExit -NonInteractive -NoProfile -WindowStyle Normal -NoLogo -Command "&{get-process}"'

$pstart =  "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

$action = New-ScheduledTaskAction -Execute $pstart -Argument $actionscript
Register-ScheduledTask -TaskName $taskname -Action $action -Trigger $triggers -RunLevel Highest -Description "Test job"



Define an array and then add the triggers into it. Remember to use the array when you register the task.


You can test the triggers on a scheduled task:

Get-ScheduledTask -TaskName 'Test Job' | select -ExpandProperty Triggers

OneNote and XML–finding pages

Pages are towards the bottom of the hierarchy in OneNote – though we still haven’t dived into the content of pages yet.


You can find the pages in your notebooks like this:


$onenote = New-Object -ComObject OneNote.Application
$scope = [Microsoft.Office.Interop.OneNote.HierarchyScope]::hsPages
[ref]$xml = ''

$onenote.GetHierarchy($null, $scope, $xml)

$schema = @{one=""}

$xpath = "//one:Notebook/one:Section"
Select-Xml -Xml ([xml]$xml.Value) -Namespace $schema -XPath $xpath |
foreach {


There’s one drawback to this – all you get is the page names:

PowerShell Summit
Personal information
Book Series
Infrastructure Architecture
PS Deep Dive
Deep Dive US12


You need to play around with Xpath a bit more to get a meaningfiul structure – ideally notebook – section – page

OneNote and XML–finding sections

I recently showed how to find the names of your OneNote notebooks.  The next level down is the section.  You can find these sections in a notebook like this:


$onenote = New-Object -ComObject OneNote.Application
$scope = [Microsoft.Office.Interop.OneNote.HierarchyScope]::hsPages
[ref]$xml = ''


$onenote.GetHierarchy($null, $scope, $xml)


$schema = @{one=""}


$xpath = "//one:Notebook/one:Section"
Select-Xml -Xml ([xml]$xml.Value) -Namespace $schema -XPath $xpath |
foreach {
$node = $psitem.Node

$npath = Split-Path -Path $node.Path -Parent
$props = [ordered]@{
   Workbook =  Split-Path -Path $npath -Leaf
   Section = $node.Name
New-Object -TypeName PSObject -Property $props


The first part of the script where the application object is created, the scope set and you get the hierarchy is the same as before.  The two scripts diverge when you get to the Xpath you’re going to use.  To find the notebooks you used:


$xpath = "//one:Notebook"


which means get me any Nodes called one:Notebook


To find the section you use:


$xpath = "//one:Notebook/one:Section"


which means any nodes called one;Section that are children of a one:Notebook node.


Remember XML is case sensitive.


Once you have the section nodes – which look like this:


name             : Quick Notes
ID               : {9EFAE9AC-0388-424A-8211-02E8FFE50666}{1}{B0}
path             : (Web)/Quick
lastModifiedTime : 2014-09-04T17:48:07.000Z
color            : #B7C997
Page             : {OneNote: one place for all of your notes, OneNote Basics}


You can extract the data you want. The path property can be used to extract the name of the note book with a little bit of Split-Path magic.


Next time you’ll see how to get down to the individual pages

LAST CALL for European PowerShell Summit 2014

This is the last call for attendee registration for the European PowerShell Summit 2014.

The Summit is in Amsterdam - 29 September to 1 October 2014. Details from the events page


Due to a change in circumstances beyond our control  we have to close public registration on 10 September 2014.


If you contact us by 10 September and ask to be able to perform a funds transfer rather than paying on line you have until 15 September 2014 to complete that transaction. No monies or registrations will be accepted after 15 September. We will not accept any new request for paying by money transfer after 10 September.


Apologies for the change in dates (the web site states registration is open until 15 September) but our hands have been forced on this.


There are still a number of places available so please register quickly if you want to attend.  The more attendees we have the better chance we have of staging a European PowerShell Summit in 2015.

WMF 5.0 September 2014 preview now available

Another preview for WMF 5.0, and PowerShell 5.0, is available for download.  Details from

OneNote and XML–finding notebooks

When OneNote first came out there wasn’t an API for it as you get for Word or Excel. A community module enabled you to work with the XML that formed the OneNote note books but it wasn’t updated after Office 2007 and doesn’t really work with later versions of OneNote.


I was looking at the Office developer site and noticed that there was some information on OneNote  This series will investigate how to script against OneNote and also expalin how to use Select-XML and XPath on the way.


A good starting point would be to discover the OneNote notebooks:

$onenote = New-Object -ComObject OneNote.Application
$scope = [Microsoft.Office.Interop.OneNote.HierarchyScope]::hsPages
[ref]$xml = ''

$onenote.GetHierarchy($null, $scope, $xml)

$schema = @{one=""}
$xpath = "//one:Notebook"
Select-Xml -Xml ([xml]$xml.Value) -Namespace $schema -XPath $xpath |
foreach {


The starting point – like all good Office applications – is a COM object that exposes the OneNote object model.  As an aside isn’t time office moved away from COM and we had a proper .NET API or even better a PowerShell module.


You also need to define the scope – in this case get all pages. The enumeration is described here


You also need to create a [ref] object to hold the output


The GetHierarchy() method is used to read through the notebooks. The $null argument means start at the top


The schema can be found inside the XML produced so to avoid a circular argument I’ll set that in a variable – it has to be a hash table as shown


Define the XPath – in this case get the nodes labelled one:Notebook


Select-XML will extract the required nodes – notice how the object has to be presented.


A simple foreacch iterates over the nodes which look like this

name             : Personal (Web)
nickname         : Personal (Web)
ID               : {F8CC78D5-9CC3-40C8-847B-96B15E3D6AD2}{1}{B0}
path             :
https://<a path>  (Web)/
lastModifiedTime : 2014-09-04T17:48:07.000Z
color            : #FFD869
Section          : {Quick Notes, Unfiled Notes, PowerShell Summit}
SectionGroup     : SectionGroup


And you can select the name of the notebook.

Patching Server Core

I’ve been rebuilding my test lab after installing a SSD into the machine running it in place of the SATA drive.  Huge improvement in load speed of virtual machines – well worth the cost.

I usually have a number of server core machines in the lab and use WSUS for patching.  One issue I’d never really resolved was patching those server core machines  - the control panel fro Windows Update isn’t available!

Finally found a solution in the Windows Update PowerShell module from

Install the module and then you can install your patches using

Get-WUInstall –AcceptAll

I’m running Windows 2012 R2 on all my servers so the modules auto load

European Summit deadline approaching

There are just over two weeks left for you to register for the European PowerShell Summit. At the moment we are still short of the number that would enable us to repeat a European Summit in 2015.  We had a lot of comments from people stating they wanted a Summit in Europe.  Now is the time to step up and support that idea.


Hope to see you there

DSC Resource Kit–wave 6

The next wave of the DSC resource kit is available with some new resources and updates to old favourites.

Details from: