Pester, the awesome PowerShell testing framework has recently introduced a capability which allows us to extend our test assertions. This allows to simplify our tests by abstracting custom or complex assertion logic away from the tests and into separate scripts or modules.
Posts by Year
In this post, we’ll look at PSCodeHealth’s default code quality metrics rules and how to customize them to our requirements. Then, we’ll use custom metrics rules in a release pipeline to decide if the build should pass or fail.
In this article, we are going to start with what we mean by ‘code quality’ and why it matters. Then, we’ll see how PSCodeHealth can help assess the quality and maintainability of a PowerShell project.
The output HTML of Jekyll-based sites may contain quite a lot a whitespace. This is especially noticeable with pages relying heavily on Liquid tags with conditional logic or looping.
Why does code complexity matter ? As Administrators or engineers, we deal with complexity all the time. We build, document, support and deploy complex systems on a pretty-much-daily basis. The expertise required to work with these systems is part of what makes us valuable. So why should we st...
When unit testing with Pester, mocking is pretty much unavoidable, especially for code related to infrastructure, configuration, or deployment. We don’t want our unit tests to touch files, databases, the registry, and not to mention the internet, do we ?
As you probably already know, when writing a DSC configuration, separating the environmental data from the configuration logic is a best practice. So all the environment-specific data gets stored in separate (typically .psd1) files. If you work with PowerShell DSC at medium-to-large scale, you (ho...
As you already know if you have read this or this, I’m a big fan of PSScriptAnalyzer to maintain a certain coding standard. This is especially powerful inside a release pipeline because this allows us to enforce that coding standard.
Nowadays, many IT shops look a lot like the first few pages of The Phoenix Project : lack of automation and communication which leads to manual and unpredictable deployments, which in turn, leads to firefighting.
Coding, especially in PowerShell, is not about remembering the exact syntax of how to do something, it is more about knowing how to try things out and to get the information we need to do whatever we need to accomplish.
I read Jeff Hicks’s article about “Dancing on the table with PowerShell”. The content is really quite fascinating (go read it !), but I got hung up on something.
Recently, I had to roll out an upgrade of our software for a customer. The upgrade failed for about 80 client machines (out of around 400). There was a lot of head-scratching and quite a few :
Unit testing PowerShell code is slowly but surely becoming mainstream. Pester, the awesome PowerShell testing framework is playing a big part in that trend.
As you probably know, PSScriptAnalyzer is a static code analysis tool, which checks PowerShell code against rules representing best practices and style guidelines. This is a fantastic tool to set coding style and quality standards, and if we want to, we can easily enforce these standards within a ...
When writing a DSC configuration, separating the environmental data from the configuration logic is a best practice : it allows to reuse the same logic for different environments, for example the Dev, QA and Prod environments.
Many of us who are writing PowerShell code are using Appveyor (especially for personal projects). And most of us use this to run Pester tests. Automated testing is great, it allows to set a certain standard of code quality without slowing down code delivery.
As you may already know, the only PowerShell certification program is being abandoned. Some people in the PowerShell community are trying to justify this by saying “There is no need for PowerShell cert” or “it’s too difficult to test PowerShell knowledge”.
Recently, I had to manage the configuration of the remote control settings of client machines with PowerShell DSC. These settings are located in the registry key HKLM:\SYSTEM\CurrentControlSet\Services\HidIr\Remotes :
PowerShell Desired State Configuration (DSC) makes it easy to apply a configuration to a bunch of servers. But what if the servers are already in production, if the update requires a service restart and we need to make this happen with no service disruption ? That’s a different story.
One of the things I love about PowerShell, is that once we know the fundamentals, we can learn the rest on our own, by just exploring and experimenting. As I like to tell people, discoverability is the number 1 feature of PowerShell.
Given the number and the complexity of certificate-related issues we get at VMware Support, I wanted an automated way to check whether a certificate file meets the vCenter Server certificate requirements.
An introduction to the PackageManagement module If you are using Windows 10 or if you have installed the Windows Management Framework 5.x available here, you may have noticed a PowerShell module named PackageManagement. This is the new name for what was called OneGet in previous versions of the ...
A while back, I saw this article from the Scripting Guy on parsing RSS feeds. Being an avid RSS feeds consumer and podcast watcher/listener, this was a “aha” moment.
The symptoms of a full RAMdisk on a ESXi host can be pretty nasty and diverse. The possible causes are also very diverse (search for ramdisk full in the VMware Knowledge Base, you will see what I mean).
As you may know, the Storage Views and Storage Reports features have been removed from vSphere 6. Here is the official (and laconic) statement from the vSphere 6.0 release notes :
Recently, I had a customer who wanted to check if the VMware Tools were installed and up-to-date using PowerCLI.
Sometimes, when trying out a cmdlet I rarely use, I get that : This means I forgot to enter a parameter which is mandatory for this cmdlet. PowerShell is very forgiving and asks me nicely to enter a value for this parameter. You see, learning PowerShell is not about rote knowledge of every sing...
When there is a OS-handled crash (a blue screen), there are some settings in the Startup and Recovery Control Panel, which tells Windows how it should behave. For example, whether it restarts automatically or not, whether it writes a small, a kernel dump or a full memory dump, and where :
The majority of my colleagues have more of a Linux background than Windows. So their cat and their grep are near and dear to their heart and their first reflex when they get into PowerShell is to replicate these commands.
I recently stumbled upon a PowerShell Script from a .NET Developer/Architect who shall remain nameless, which contained this :
“Have you tried turning it off and on again?” This quote from IT Crowd reflects probably the most universal stereotype about IT support. By the way, using this shortcut instead of actually diagnosing the problem shouldn’t be the usual course of action. But still, a reboot can really save you ...
If there is a process hanging or consuming CPU resources and you have no idea why, a good place to start is to have a look at its threads and what they are doing. Fortunately, Threads are a property of the object you get when run Get-Process :