Function: Expand-ZipFile

Fellow coders, I’ve got a quick and dirty function for you. I had the requirement to extract zip files from a particular directory. Of course you could do this with Expand-Archive (new in PowerShell 5). But there’s a problem with this little rascal; it does not keeps the timestamps of the zipped files intact. My customer wanted to keep these timestamps intact, because they use it as a indicator to see if the file is older or newer what they already have. So I made a quick and dirty function, which uses a .NET assembly. I based this function on […]


Automating with Jenkins and PowerShell on Windows

Take a minute think about how many PowerShell scripts you have written for yourself or your team. Countless functions and modules, helping to automate this or fix that or make your teams lives easier. You spend hours coding, writing in-line help, testing, packaging your script, distributing it to your team. All that effort, and then a lot of the time the script is forgotten about! People just go back to doing things the manual way. I put this down to being out of sight, out of mind. Users who do not use the command line regularly will quickly forget about […]



The Monad Manifesto Annotation Project

Richard’s log, stardate 2457164.5 Today’s destination is the Monad Manifesto Annotation Project. The idea behind this project is to keep the manifesto intact somewhere on the internet, and to provide the possibility to the community to annotate on the several topics in the manifesto. The idea for this came from Pluralsight author Tim Warner, with the initial annotations being made by Don Jones. Jeffrey Snover gave his permission for this project, but with a big warning: the content only can be shared on the original source page on penflip, and cannot be hosted anywhere else. I am already in the […]


PowerShell… An exciting frontier…

boldlygo_preview

PowerShell… An exciting frontier… These are the voyages of a PowerShell adventurer. Its continuing mission: To explore strange new cmdlets… To seek out new modules; new parameters… To boldly go where no one has gone before!” Richard’s log, stardate 2457163. Our destination for today is my very first post on PowerShell.org. As you can see, from the opening lines, I approach my journey in PowerShell as a exploration into the unknown, just like the crew of Star Trek, Next Generation did. Till now my journey has been a pleasant one, because you know, exploring PowerShell is a lot of fun! […]


Proxy Functions for Cmdlets with Dynamic Parameters

I came across an interesting problem today while working on the Pester module: how do you create a proxy function for a Cmdlet which has dynamic parameters? I needed a solution which would automatically reproduce the original cmdlet’s dynamic parameters inside a PowerShell function, and which would work on PowerShell 2.0 if at all possible. The full post and solution can be found on my blog at http://davewyatt.wordpress.com/2014/09/01/proxy-functions-for-cmdlets-with-dynamic-parameters/. Related posts: PowerShell Gotcha: UNC paths and Providers PowerShell and System.Nullable<T> Tracking down commands that are polluting your pipeline


DSC Pull Server on Windows Server 2008 R2

Recently on the PowerShell.org forums, a community member mentioned that they were having trouble setting up a Server 2008 R2 machine as a DSC pull server. It turns out, this is possible, but you have to install all the prerequisites yourself, since the Add-WindowsFeature DSC-Service command doesn’t do it for you on the older operating system. Refer to this blog post for the checklist. Related posts: Building a Desired State Configuration Pull Server Building a Desired State Configuration Configuration – Part 2 Configuring a Desired State Configuration Client Building Scalable Configurations With DSC


Tracking down commands that are polluting your pipeline

In a recent forum post, someone was having trouble with a function that was outputting more values than he expected. We’ve all been there. He was having trouble debugging this, and I decided to see if I could find a way to narrow down the search in an automated fashion, rather than having to step through the code by hand. The full article and code are up on my blog at http://davewyatt.wordpress.com/2014/06/05/tracking-down-commands-that-are-polluting-your-pipeline/ Related posts: Saving Passwords (and preventing other processes from decrypting them) PowerShell Gotcha: UNC paths and Providers Working on a new PowerShell module: ProtectedData Proxy Functions for Cmdlets […]


Patterns for Implementing a DSC Pull Server Environment

My Patterns for Implementing a DSC Pull Server Environment talk from the PowerShell Summit is now online. Enjoy! Related posts: Life and Times of a DSC Resource Building Scalable Configurations With DSC Desired State Configuration – General Availability Changes Going Deeper on DSC Resources


Building Scalable Configurations With DSC

My Building Scalable Configurations with DSC talk from the PowerShell Summit is now online. Enjoy! Related posts: Life and Times of a DSC Resource Patterns for Implementing a DSC Pull Server Environment Desired State Configuration – General Availability Changes Going Deeper on DSC Resources


Life and Times of a DSC Resource

My Life and Times of a DSC Resource talk from the PowerShell Summit is now online. Enjoy!   Related posts: Building Scalable Configurations With DSC Patterns for Implementing a DSC Pull Server Environment Desired State Configuration – General Availability Changes Going Deeper on DSC Resources


Installing PowerShell v5? Be a Little Careful, OK?

I’m getting a lot of questions from folks, via Twitter and other venues, regarding Windows Management Framework 5.0 – which is where PowerShell v5 comes from. It’s awesome that people are installing v5 and kicking the tires – however, please help spread the word: v5 is a preview. It isn’t done, and it isn’t guaranteed bug-free. It shouldn’t be installed on production computers until it’s officially released. v5 doesn’t install ‘side by side’ with v3 or v4. You can’t run it with “-version 3″ to “downgrade.” Now, v5 shouldn’t break anything – something that runs in v3 or v4 should […]


Going Deeper on DSC Resources

Desired State Configuration is a very new technology and declarative configuration management is a very young space yet.  We (Microsoft and the community) are still figuring out the best structure for resources, composite configurations, and other structures. That said, there are certain viewpoints that I’ve come to, either from hands on experience or in watching how other communities (like the Puppet community or Chef community) handle similar problems. How Granular Should I Get? There is no absolute answer. Very, Very Granular Resources should be very granular in the abstract, but in practice, you may need to make concessions to improve […]


PowerShell and System.Nullable<T>

While helping to answer a question about Exchange cmdlets today, I came across something interesting, which doesn’t seem to be very well documented. A little background, first: in the .NET Framework (starting in Version 2.0), there’s a Generic type called System.Nullable<T>. The purpose of this type is to allow you to assign a value of null to Value types (structs, integers, booleans, etc), which are normally not allowed to be null in a .NET application. The Nullable structure consists of two properties: HasValue (a Boolean), and Value (the underlying value type, such as an integer, struct, etc). A C# method […]


PowerShell Gotcha: UNC paths and Providers

PowerShell’s behavior can be a little bit funny when you pass a UNC path to certain cmdlets. PowerShell doesn’t recognize these paths as “rooted” because they’re not on a PSDrive; as such, whatever provider is associated with PowerShell’s current location will attempt to handle them. For example: Set-Location C: Get-ChildItem -Path \\$env:COMPUTERNAME\c$ Set-Location HKLM: Get-ChildItem -Path \\$env:COMPUTERNAME\c$ The first command works fine (assuming you have a c$ share enabled and are able to access it), and the second command gives a “Cannot find path” error, because the Registry provider tried to work with the UNC path instead of the FileSystem […]