Be Mindful of Object Types when Writing Unit Tests and Performing Operational Validation in PowerShell with Pester

I recently wrote a Pester test that performs some basic operational validation (smoke tests) of SQL Servers. I've previously written similar tests as functions as shown in my "Write Dynamic Unit Tests for your PowerShell Code with Pester" blog article, but I decided to write this one as a script with the naming convention that seems to be recommended. The name of this particular test is "Validate-MrSQLServer.Tests.ps1". You're probably thinking "Validate" isn't an approved verb and you're right, Read more [...]

Keeping Track of PowerShell Functions in Script Modules when Dot-Sourcing PS1 Files

I'm picking up where I left off in a previous blog article "Write Dynamic Unit Tests for your PowerShell Code with Pester". I'm using the dynamic Test-MrFunctionsToExport Pester test that I wrote about in that previous blog article. Currently, the test is failing for my MrToolkit module that's part of my PowerShell repository on GitHub: Based on the previous results, I can easily determine that more functions exist in the module folder than are specified in Read more [...]

Video: Creating a Custom PowerShell Toolkit to Demystify DSC

Last week, on Monday (April 4th, 2016), I presented a session at the PowerShell and DevOps Global Summit 2016 on "Creating a Custom PowerShell Toolkit to Demystify the Intricacies of Desired State Configuration". The video from that presentation is now available: https://youtu.be/fOov9gkqFHs Here’s the abstract or synopsis for this presentation: "DSC (Desired State Configuration) can be very complicated when working in an environment where nodes are set to retrieve their configuration from Read more [...]

Video: Building Unconventional SQL Server Tools in PowerShell

Last week, on Wednesday (April 6th, 2016), I presented a session at the PowerShell and DevOps Global Summit 2016 on "Building Unconventional SQL Server Tools in PowerShell with Functions and Script Modules". The video from that presentation is now available: https://youtu.be/2rEzMWdTFDk Here's the abstract or synopsis for this presentation: "Have you ever had records from a SQL Server database table come up missing? Maybe someone or some process deleted them, but who really knows what happened Read more [...]

Write Dynamic Unit Tests for your PowerShell Code with Pester

I wrote a blog article on: "PowerShell Script Module Design: Placing functions directly in the PSM1 file versus dot-sourcing separate PS1 files" earlier this year and I've moved all of my PowerShell script modules to that design and while today's blog article isn't part of a series, that previous one is recommended reading so you're not lost when trying to understand what I'm attempting to accomplish. Most unit tests that I've seen created with Pester for testing PowerShell code are very specific, Read more [...]

A Rant about some Blogs, Magazine Articles, Books, Training Videos, Presentations, Etc

<Begin Rant> I find it funny, yet sad that I often see blogs, magazine articles, books, training videos, presentations, etc where the author says something to the effect of "Never do <fill in the blank>". Then they proceed by doing exactly what they just said not to do like four-hundred times throughout their book, blog, etc. and when asked about it, the author says "Oh, that's only acceptable for demonstration purposes". I also see this in the form of an author saying something to Read more [...]

Converting a SQL Server Log Sequence Number with PowerShell

As demonstrated in one of my previous blog articles "Determine who deleted SQL Server database records by querying the transaction log with PowerShell", someone or something has deleted records from a SQL Server database. You've used my Find-MrSqlDatabaseChange function to determine when the delete operation occurred based on information contained in either transaction log backups or the active transaction log: You're ready to perform point in time recovery Read more [...]

Pro Tips from the Trenches: The Resolve-Path PowerShell cmdlet

You're designing a reusable tool in PowerShell and decide a function is the most appropriate type of command to accomplish the task at hand. It will accept a FilePath parameter which will be used to specify both the path and filename to a destination file. The path should already exist, but the file may or may not already exist. For simplicity, I've stripped away the complexity so the problem is more apparent. This function validates that the parent path exists and then returns the absolute path Read more [...]

Run 350 Nano Server Virtual Machines on a Lenovo ThinkPad P50 with Hyper-V in Windows 10

If you're a frequent reader of my blog articles on this site, then you're already aware that I recently purchased a Lenovo ThinkPad P50 with a Xeon CPU, 64 GB of RAM, and upgraded it to SSD hard drives as shown in my previous blog article. I tweeted that it wouldn't be complete without a few PowerShell stickers: I received a response from Jeffrey Snover wanting to know how many Nano server VM's could be run on it: I took that as a challenge and decided to spin up as many Nano server Read more [...]

Upgrade to SSD Hard Drives in a Lenovo ThinkPad P50

I recently purchased a Lenovo ThinkPad P50. It's certainly not the sleekest machine on the market, but don't judge a book by its cover. I picked this model because it offers an Intel Xeon CPU and up to 64 GB of RAM in a 15 inch laptop. My previous computer was a Dell Latitude e6530 which is about the same form factor, although the older one is a little thicker and slightly larger and heavier due to the extended battery that sticks out of the back of it. The ThinkPad doesn't have an optical drive Read more [...]

Determine the Packt Publishing Free eBook of the Day with PowerShell

First of all, let me state that I'm in no way affiliated with Packt Publishing other than being a customer. They offer a free eBook each day and that information is freely available on the Internet. Like any information on the web, it's publicly available and you can read it with a web browser or with something like PowerShell. As shown in the following example, a PowerShell one liner can be used to determine their free eBook of the day: This requires PowerShell Read more [...]

Use PowerShell to Add Active Directory Users to Specific Groups based on a CSV file

I recently responded to a post in a forum about adding Active Directory users to groups with PowerShell based on information contained in a CSV (Comma Separated Values file format). I thought I would not only share the scenario and solution that I came up with but also elaborate on adding additional functionality that may be desired. In this scenario, you’ve been provided with a CSV file that contains a list of Active Directory users and the groups that they should be a member of as shown in Read more [...]

Git status doesn’t know if your local repository is out of date

To setup the scenario that will be demonstrated in this blog article, a new commit has been pushed to the dev branch of my PowerShell repository on GitHub from a computer named PC01. Then I switched over to using to an alternate computer named PC02 that was up to date prior to that latest commit being pushed to GitHub from PC01. This means that the dev branch of the PowerShell repository on PC02 is one commit behind the remote origin on GitHub. You would think that checking the status of the dev Read more [...]