Lessons Learned

My drop-site for interesting snippets and tips. If it's useful to you as well, great!

Selecting an XML Element by #text value

This is actually just a wrapper for the [text()=’value’] XPATH attribute.  As I said in a...

Author: timdunn Date: 04/02/2014

PowerShell for N00bs: Libraries, Paths, and You

One of the scripts a coworker inherited has the following workflow: 1. Set-Location...

Author: timdunn Date: 03/27/2014

PowerShell –EncodedCommand and Round-Trips

PowerShell.exe accepts the –EncodedCommand parameter, which is a way to ‘wrap’ DOS-unfriendly...

Author: timdunn Date: 03/26/2014

Scripting Best Practices, or Write-Host Considered Harmful

Disclaimer: this is going to sound like I actually know what I’m doing.  Let’s be honest – I...

Author: timdunn Date: 03/25/2014

Hotkeys and RDC Man

There are days I seem to live on RDC Man.  One day, I might try setting my Shell= to...

Author: timdunn Date: 03/21/2014

Do-Something | Set-Variable Foo

Especially for stuff that generates a lot of output, I’ve learned to pipe commands to...

Author: timdunn Date: 03/19/2014

Function Skeleton for Invoke-Command –AsJob

PSRemoting jobs are quite amazing. While they are a little complicated to grasp at first,...

Author: timdunn Date: 03/17/2014

Parsing Dates by Hand

I’m always impressed by the amount of variety in input formats that Get-Date can accept and still...

Author: timdunn Date: 03/14/2014

CredLocker – Storing PSCredentials to File

Summary CredLocker is tool to securely store PSCredentials to a file such that the file can be...

Author: timdunn Date: 03/12/2014

Invoke-WebRequest, a First Attempt

“To learn PowerShell, you first have to have a problem to solve.” Well, this is utterly...

Author: timdunn Date: 03/10/2014

Capturing Write-Noun Cmdlet Output

I’m sure there’s a cleaner way to capture the output from Write-Host, Write-Verbose, etc. ...

Author: timdunn Date: 03/04/2014

One-Liner: Getting My Documents and Other Special Folders

I have roaming profiles, which is great until I need to reference stuff in my Documents folder....

Author: timdunn Date: 03/03/2014

WMI and HP Product IDs

An HP Product ID is related to the hardware SKU The plain-English way of getting the SKU is...

Author: timdunn Date: 02/28/2014

Enums, Enums, Enums, a One-Liner

Enums are short for Enumerations, which is a fancy way of saying, “map this [string] to that...

Author: timdunn Date: 02/27/2014

WMI-Less Network Adapters

We can get a list of network adapters (calling them NICs is a bit outdated: the C in NIC stands for...

Author: timdunn Date: 02/26/2014

Getting Event Logs with wevtutil.exe

A long time ago, I wrote a painful way to export event logs (to CSV) on Server 2003, which lacks...

Author: timdunn Date: 02/25/2014

One-Liner: Resetting Desktop Toolbar

For some reason,...

Author: timdunn Date: 02/24/2014

Those Who Don’t Know Their History…

My function:\prompt changes every so often. For my latest, see...

Author: timdunn Date: 02/21/2014

I Should Have Done This Years Ago (New-Shortcut, Revisited)

In spite of having this blog, sometimes I rewrite a function because I forgot I wrote it...

Author: timdunn Date: 02/20/2014

Meatball Surgery, the Taskbar, Toolbars, and You

It takes me a while, but when I get used to something, I hate to change.  Windows 7 introduced...

Author: timdunn Date: 02/19/2014

The Clipboard

Talk about a sea change. I started off wondering how to read text out of the clipboard. Thanks to...

Author: timdunn Date: 02/18/2014

Finding Disk Hogs (i.e. Large Folders)

“Disk full? It was only at 60% last week! Where did all the space go?” If you...

Author: timdunn Date: 02/14/2014

Sanity-Checking RDG Files

Remote Desktop Connection Manager is a must-have tool. However, it too easily falls out of date....

Author: timdunn Date: 02/12/2014

Modules vs. Scripts: It’s Not Just the Letter ‘M’

Here’s an interesting gotcha if you are spawning a new window for asynchronous execution via the...

Author: timdunn Date: 02/11/2014

Stupid Profile Trick: $PROFILE as Module

I’m spending a lot of time on my $PROFILE for some reason.  Don’t tell my boss. :) Anyhow, we...

Author: timdunn Date: 02/10/2014

Prompts

What does your function:\prompt look like? Here’s mine: function prompt { if...

Author: timdunn Date: 02/07/2014

CorpNet ProjectFunctionLibrary.psm1

Sorry, nothing really intranet related here. Instead, I have a few lines of code from my CorpNet...

Author: timdunn Date: 02/06/2014

Getting Disk Usage

No time to document it.  Had to throw something together, so here it is. function Get-DiskUsage...

Author: timdunn Date: 02/04/2014

Getting an SHA256 Hash

To steal from the .DESCRIPTION section of the comment-based help: “Yes, PowerShell3 has...

Author: timdunn Date: 02/03/2014

Loop-de-Loop

Here’s a quick trivia question for you: Given the following two looping constructs: foreach ($item...

Author: timdunn Date: 01/30/2014

Read-Host With a Timeout, Kind Of…

Let’s copy the stuff from the comment block first: This is an unholy union of...

Author: timdunn Date: 01/29/2014

Testing Timestamps of Files Across a Slow Network

I’m not sure if this is because of network lag, or the fact that my lab is on a different AD domain...

Author: timdunn Date: 01/28/2014

Getting Version Data From Comment Based Help

Disclaimer: There’s a lot of parse-by-prayer here. You Have Been Warned. Here’s the...

Author: timdunn Date: 01/27/2014

One-Liner(s): X509 Certificate Store Names and You

All right, we know that we can access a remote computer's various X509Certificate stores via .NET,...

Author: timdunn Date: 10/25/2013

One-Liner: Case-Insensitive XML Queries

I'm a one-trick pony with XML. I use $xml.SelectNodes("//name[@attribute='value']") and permutations...

Author: timdunn Date: 10/24/2013

Regular Expressions, Search-and-Replace Interpolation and Delegates

This (and the previous post) stem from me stumbling onto this page:...

Author: timdunn Date: 10/07/2013

Splitting a Hex-Encoded String into Pairs of Hex Characters (a.k.a. To Pull a Noah)

Simple enough task: I have a hex-encoded string and need to decode it.  Now, we all know that...

Author: timdunn Date: 10/04/2013

Tip: Passing [switch]Parameters to Nested Functions

Here's something that bedeviled me for the longest time: if I have a [switch] type parameter at the...

Author: timdunn Date: 09/25/2013

Rehash: Playing with Window Size

https://blogs.msdn.com/b/timid/archive/2011/06/23/playing-with-window-size.aspx gave the core magic...

Author: timdunn Date: 09/24/2013

Capturing the Console Buffer

Vladimir Averkin’s...

Author: timdunn Date: 09/23/2013

Lenovo W530 and the Context Menu Key

The context menu key looks like this: It’s normally on the same row as the space bar, usually...

Author: timdunn Date: 09/19/2013

Windows 8, the F8 Key, and You

Welcome to Windows 8.  Quick, how do you revert back to the last system restore point?  To...

Author: timdunn Date: 09/11/2013

Printing to Text

Yes, you can still print to a file in Windows 8. Very handy. Start | Control Panel | Devices |...

Author: timdunn Date: 09/10/2013

BitLocker and Self-Immolation

My primary device is corporate-owned, and contains a lot of corporate data. Policy says to have it...

Author: timdunn Date: 09/09/2013

Stupid Microsoft Word Trick: Boilerplate Text (Same Source Text, Multiple Instances)

This one is a Word feature cursed by utterly non-intuitive names. The concept is simple: I want to...

Author: timdunn Date: 08/30/2013

Stupid Microsoft Word Trick: Multilevel Numbered Headings

I don’t work with MS Word all the time, so I end up having to re-discover this trick each...

Author: timdunn Date: 08/29/2013

Drive-by: PowerGUI Visual Studio Extension

Adam Driscoll has embedded PowerGUI's script editor engine in Visual Studio. Unfortunately, it...

Author: timdunn Date: 08/27/2013

<Previous Next>