Begin-Process-End in a PowerShell script

Much has been written about how you need to use Begin/Process/End blocks in order to handle a collection of values passed from the pipeline, but those posts all seem to focus on how to do it in a *function*, not a script.

I recently struggled to figure out how to retrofit this functionality into one of my existing PowerShell scripts.

If you’re here I guess you already know WHY you want to do it, but it’s the HOW what’s causing you distress.

Seen this and had your script dump a list of running processes to screen?

begin : The term 'begin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is correct and try again.

The trick is simple: there can be NO executable code outside the B/P/E blocks. Nothing. No ‘statics’, no hash tables declared, no functions, not a sausage. Once you move the lot into the Begin block, it’s plain sailing.

Continue reading ‘Begin-Process-End in a PowerShell script’ »

Adventures with Import- and Update-CsUserData Pt.4

I’ve spent a lot of time in the past 12 months working with the <verb>-CsUserData commandlets in SfB, and it’s been an interesting time.

This is part 4 in a series where I document the traps I’ve fallen into with the Import-CsUserData and Update-CsUserData commands in particular.

Part 1 – Update-CsUserData fails on bad data.
Part 2 – Your Front-End won’t start after Import-CsUserData imports bad data.
Part 3 – Update-CsUserData throws false red and runs slow if your paired pool is offline.
Part 4 – You can’t trust Import-CsUserData to tell you if it fails.

Part 4 – You can’t trust Import-CsUserData to tell you if it fails

Having abandoned Update-CsUserData we moved to Import-CsUserData, but that wasn’t the bed of roses we were expecting either.

TL;DR: DON’T run “Import-CsUserData” without the -Verbose switch, and make sure you pay attention to its output. If it has some objection to your XML or ZIP file it might silently fail. Only with the -Verbose switch will you know for sure*.

(*) And even then I wouldn’t bank my career on it.

Continue reading ‘Adventures with Import- and Update-CsUserData Pt.4’ »

Adventures with Import- and Update-CsUserData Pt.3

I’ve spent a lot of time in the past 12 months working with the <verb>-CsUserData commandlets in SfB, and it’s been an interesting time.

This is part 3 in a series where I document the traps I’ve fallen into with the Import-CsUserData and Update-CsUserData commands in particular.

Part 1 – Update-CsUserData fails on bad data.
Part 2 – Your Front-End won’t start after Import-CsUserData imports bad data.
Part 3 – Update-CsUserData throws false red and runs slow if your paired pool is offline
Part 4 – You can’t trust Import-CsUserData to tell you if it fails.

Part 3 – Update-CsUserData throws false red and runs slow if your paired pool is offline

TL;DR: If you have paired pools, Update-CsUserData will throw red – appearing to fail – and potentially take a LONG time to execute if your paired pool is offline / failed over. Even if it’s still responding, if that other PoolState is FailedOver, you’re in dangerous territory.

Continue reading ‘Adventures with Import- and Update-CsUserData Pt.3’ »

SfBS RGS lets you spoof a SIP Domain


 
A long-standing bug in Skype for Business’s Response Group Service (“RGS”) is that it doesn’t validate the line URI when you create a new Workflow. This means it won’t err out if you chose a number that’s already in use elsewhere, and the upshot is that neither the existing user nor the response group can be called. Tracing will reveal a “SIP/2.0 485 Ambiguous” error.

But did you know it doesn’t validate the SIP Domain either?

You can create a Workflow for ANY SIP domain, and not only will it save it without error – it will route!

Continue reading ‘SfBS RGS lets you spoof a SIP Domain’ »

Get-WeatherLinkData.ps1

We’ve had a Davis Instruments Vantage Vue weather station on the roof for some time now, and with the addition of the “WeatherLinkIP datalogger” its data is uploaded to the greater Davis WeatherLink platform automatically.

Their service is subscription-based, and we’ve not seen sufficient value in giving them ~AUD5/month to have access to the historical data, so we’re stuck on the quasi “real-time only” free tier.

We happen to use the free version of Paessler’s PRTG Network Monitor to monitor all we have here, and it recently occurred to Rocky to see if we could capture the weather station’s data as well. Turns out that’s a YES.

Continue reading ‘Get-WeatherLinkData.ps1’ »

2020 mugshot: an ivory 400-series handset

The phone in my ‘mugshot’ this year is, like me, quite a relic. It’s an ivory-coloured handset from a 400-series phone.

At the start of last century telephones were typically constructed of timber or metal. It wasn’t until the late 1920’s that the British Siemens company developed the first plastic phone, made of a “thermo setting phenolic material”.

Continue reading ‘2020 mugshot: an ivory 400-series handset’ »

Lync 2013 / SfB 2015 Client Update – August 2019

As per my previous post, I’ve just realised I’ve missed TWO client updates this year.

The second of these was from August. Kb 4475564 took us from 15.0.5153.1001 to 15.0.5159.1000 – although the KB lists it as 15.0.5163.1000.

What’s Fixed

  • Kb 4513494 HTML messages sent to Skype for Business display incorrect font in Export-CsArchivingData output

What’s New / Changed

Nothing documented.

Known Issues

Nothing documented.

Continue reading ‘Lync 2013 / SfB 2015 Client Update – August 2019’ »

Lync 2013 / SfB 2015 Client Security Update – July 2019

Here we are boldly staring down Christmas again for another year, and I’ve just realised not one but TWO updates to the Office 2013-based Skype for Business client have snuck past me in recent months. (Well, at least I have a handy New Year’s Resolution up my sleeve now…)

The previous update was June, and this security update (Kb 4475519) took us from 15.0.5145.1000 to 15.0.5153.1001.

What’s Fixed

“This security update resolves an information disclosure vulnerability that exists if Microsoft Exchange allows entities to be created even though they have Display Names that contain non-printable characters. To learn more about the vulnerability, see Microsoft Common Vulnerabilities and Exposures CVE-2019-1084“.

What’s New / Changed

Nothing documented.

Known Issues

Nothing documented.

Continue reading ‘Lync 2013 / SfB 2015 Client Security Update – July 2019’ »

Our annual housewarming – the DHMG

Rocky and I bought our first home together back in late 1995. It was a lovely 3-bedroom semi-detached house in one of the inner-western suburbs of Sydney.

We found ourselves holding a housewarming for it in January 1996, and for some reason lost to history we settled on a parody / lampooning of the poster for the annual Sydney Gay & Lesbian Mardi Gras, re-creating the organisation and re-convening its signature event a few suburbs to the west.

Original image credit: artsandculture.google.com. Original poster art: Glenn A Moffat.

Somehow the party became an annual celebration. Certainly the venue lent itself to a late-Summer party, with the airy internals complemented nicely by the small patch of green out the front, and the small backyard.
Continue reading ‘Our annual housewarming – the DHMG’ »

Adventures with Import- and Update-CsUserData Pt.2

I’ve spent a lot of time this year working with the <verb>-CsUserData commandlets in SfB, and it’s been an interesting time.

This is part 2 in a series where I document the traps I’ve fallen into with the Import-CsUserData and Update-CsUserData commands in particular.

Part 1 – Update-CsUserData fails on bad data.
Part 2 – Your Front-End won’t start after Import-CsUserData imports bad data.
Part 3 – Update-CsUserData throws false red and runs slow if your paired pool is offline.
Part 4 – You can’t trust Import-CsUserData to tell you if it fails.

In Part 1 I showed how Update-CsUserData will throw an error if you try to import “bad data” – and in that example this boiled down to two occurrences of the same “buddy” in a contact file exported from Lync 2010.

What do you think happens if you try to import the same XML/ZIP file using Import-CsUserData? I’m glad you asked.

Part 2 – Your Front-End won’t start after Import-CsUserData imports bad data

TL;DR: It looks like there’s not a lot of validity checking in “Import-CsUserData”. Provided the file is valid XML, the DLL(?) that does the work just copies the Buddy data – as XML – directly into the back-end SQL database. The problems arise later when the Front-End SQL database parses that XML and tries to plug it into its own tables where each Buddy is a Primary Key and MUST be unique. Now you’re in strife.

I believe you’ll only be impacted if your source is formatted as Lync 2010 data.

Continue reading ‘Adventures with Import- and Update-CsUserData Pt.2’ »