Category: PowerShell

Video: PowerShell 101 – The No-Nonsense Beginner’s Guide to PowerShell

Last week, I announced a new book for PowerShell beginners that I'm self-publishing. I decided to create a short video about the book and cover the topics from Chapter 1. The video can also be found on The book (PowerShell 101: The No-Nonsense Beginner’s Guide to PowerShell) can be found on µ Read more [...]

Announcing a new book: PowerShell 101 – The No-Nonsense Beginner’s Guide to PowerShell

I've contributed, co-authored, performed technical reviews and edits on a number of PowerShell books. I also speak to a lot of beginners at user group meetings and technology events such as PowerShell Saturday's and SQL Saturday's. One thing I've found is there are still a lot of IT Pro's out there who are reluctant to learn PowerShell and they're often overwhelmed by information overload when they do try to learn it. What I mean by that is those of us who are fired up about going out there and educating Read more [...]

Beware of the PowerShell Update-ModuleManifest Function

I recently presented a session for the Mississippi PowerShell User Group on PowerShell Non-Monolithic Script Module Design. While preparing for that session, I discovered that a problem I had previously experienced with Update-ModuleManifest when trying to update the FunctionsToExport section when FormatsToProcess is specified appeared to be resolved in PowerShell version 5.1 (I'm running build 14393). The details of this bug can be found here. I also noticed that Nicholas Getchell had written about Read more [...]

Using PowerShell to Audit Antivirus Updates on your Servers

How often do you check to make sure that things like antivirus has received the latest definition files on all of your servers? There's probably some centralized GUI interface somewhere that you could log into and check. The antivirus product itself may even have some sort of notification system that sends alerts if the updates fail. Both of those options provide data in a format that can't be worked with and what happens if something falls through the cracks? Are you willing to bet your job and Read more [...]

No PowerShell Cmdlet to Start or Stop Something? Don’t Forget to Check for Methods on the Get Cmdlets

Many PowerShell commands return output in the form of objects (some return nothing at all). An example of this is shown in the following example where properties and their corresponding values are returned. CommandType is a property and Cmdlet is the value for that particular property for each of the results: Keep in mind that what is shown in the default output may not be the actual property names (compare the default output from Get-Process to the properties Read more [...]

Loop through a collection of items with the Pester TestCases parameter instead of using a foreach loop

One of the huge benefits of attending in-person technology events is getting to network with others. While at the MVP Summit last month I had a chance to demonstrate some of my PowerShell code and Pester tests to Jim Truher.  I was developing the code and tests for a session to present for the PowerShell Virtual Chapter of SQL PASS (the code and a video of that presentation can be found here). In one of my examples, I was looping through a collection of items (computer names of SQL Servers) Read more [...]

Locations for Comment-based Help in PowerShell Functions

One of the first things you'll learn when beginning with PowerShell is how to use the help system. When working from the PowerShell console, I use the help function and omit the Name parameter since it's positional and then specify the name of the cmdlet that I'm looking for help on as shown in the following example. This same type of standardized help can be added to your PowerShell functions and scripts which makes it easy for others to learn how to use them. Read more [...]

Learn to Query WMI (Windows Management Instrumentation) from PowerShell with SAPIEN WMI Explorer 2016

One of the reasons I like mentoring others and teaching them how to use PowerShell is that I spent the first third of my career pointing and clicking in the GUI. Before PowerShell was released, I had taken a three day MOC (Microsoft Official Curriculum) course on VBScript and two more days on WMI (Windows Management Instrumentation). I wrote a few VBScripts over the years but never really had a desire to learn it like I have PowerShell. I could write a VBScript if required but it seemed too developer Read more [...]

Write a GUI on Top of Existing PowerShell Functions with SAPIEN PowerShell Studio 2016

This blog article will demonstrate how to write a GUI on top of your existing PowerShell functions using SAPIEN PowerShell Studio 2016. I've previously written a couple of functions for managing SQL Server agent jobs. These two functions, Get-MrSqlAgentJobStatus and Start-MrSqlAgentJob can be found in my SQL repository on GitHub. Launch PowerShell Studio. Select file, the arrow next to new, and new form: For this particular GUI, I'll select the "Dialog Style Template" since I want a fixed Read more [...]

PowerShell Function to Check the Status of a SQL Agent Job using the .NET Framework

My previous blog article demonstrated how to start a SQL agent job using the .NET Framework from PowerShell to eliminate the dependency of needing the SQL Server PowerShell module or snap-in on the machine where the command is being run from. There's not much use of blindly starting a SQL agent job without being able to check the status of it so I decided to write another function to accomplish that task. If the machine where the code is being run from has the SQL Server PowerShell module that Read more [...]

Start a SQL Agent Job with the .NET Framework from PowerShell

As of this writing, the most recent version of the SQLServer PowerShell module (which installs as part of SQL Server Management Studio) includes cmdlets for retrieving information about SQL agent jobs, but no cmdlets for starting them. I recently ran into a situation where I needed to start a SQL agent job from PowerShell. The solution needed to be a tool that others could use who may or may not have the SQLServer module, SQLPS module or older SQL Server snap-in Read more [...]

Video: Automate Operational Readiness and Validation Testing of SQL Server with PowerShell and Pester

I recently presented a session on "Automate Operational Readiness and Validation Testing of SQL Server with PowerShell and Pester" for the PowerShell Virtual Chapter of SQL PASS. The video from that presentation is now available: Both the code and slide deck from the presentation can be found in my presentations repository on GitHub. µ Read more [...]

Webinar: Automate Operational Readiness and Validation Testing of SQL Server with PowerShell and Pester

I'll be presenting a webinar on how to "Automate Operational Readiness and Validation Testing of SQL Server with PowerShell and Pester" for the PowerShell Virtual Chapter of SQL PASS on Wednesday, November 16th at 11am CST. How do you know whether or not all of the SQL Servers in your environment are configured based on your organizations standards? How do you know whether or not they are all operating properly when maintenance is performed on the systems in your environment? During this Read more [...]

PowerShell Function to Validate Both IPv4 and IPv6 Addresses

Last week, I wrote a blog article about the IP address type accelerator in PowerShell not being 100% accurate and I demonstrated using it for parameter validation. If you want to simply validate an IP Address and return a Boolean, that's a little more complicated so I decided to write a function to perform that task along with providing detailed information about the IP address when an optional detailed parameter is specified: The IpAddress parameter can accept Read more [...]

PowerShell IP Address Type Accelerator Not 100% Accurate

Testing whether or not an IP Address is valid with PowerShell is a fairly simple process with the [ipaddress] type accelerator if your goal is to validate input for a script or function as shown in the following code example: When a valid IP address is specified, the function continues and when an invalid IP address is specified, the function terminates immediately and returns an error message: The IP Address type accelerator Read more [...]

PowerShell Function to Determine Available Drive Letters

I've recently been working on some file server drive migrations. One of the steps I needed to perform was to change the drive letter of a current drive to a different available drive letter so I decided to write a PowerShell function to accomplish the task of determining what drive letters are available. The Get-MrAvailableDriveLetter function shown in the following code example will run on systems with PowerShell version 2.0 or higher (I tested it all the way down to version 1.0, but that was Read more [...]