Author: Mike F Robbins

Mike F Robbins is a Microsoft MVP on Windows PowerShell and a SAPIEN Technologies MVP. He is a co-author of Windows PowerShell TFM 4th Edition and is a contributing author of a chapter in the PowerShell Deep Dives book. Mike has written guest blog articles for the Hey, Scripting Guy! Blog, PowerShell Magazine, and He is the winner of the advanced category in the 2013 PowerShell Scripting Games. Mike is also the leader and co-founder of the Mississippi PowerShell User Group. He blogs at and can be found on twitter @mikefrobbins.

Generate a Secret Santa List with PowerShell

It's supposed to be the most wonderful time of the year and while you might buy multiple Christmas gifts for everyone in your immediate family, often times buying for everyone in your extended family or for all of your co-workers is cost prohibitive. I originally started out with a simple idea to create a PowerShell script to take a list of names and generate a second random list of names based off of the first one while making sure the corresponding name on the second list doesn't match the first Read more [...]

Retrieve Basic Operating System Information with PowerShell

PowerShell version 5.1 added a new cmdlet named Get-ComputerInfo which retrieves lots of information from the local computer. It can be wrapped inside of the PowerShell remoting Invoke-Command cmdlet to retrieve that same information from remote computers. My biggest complaint with Get-ComputerInfo is that it takes forever to return the information and then when it does finally complete, it's missing values for most of its properties. Also, if you're going to wrap it inside of Invoke-Command, Read more [...]

Determine the Start Time of a Windows Service with PowerShell

Recently, I was asked to setup a scheduled task or job to restart specific services on certain servers each night and while that's simple, how do you know for sure the services were indeed restarted? One way is to determine how long a service has been running or when they were started. The dilemma is the necessary information isn't available using the Get-Service cmdlet or with CIM or WMI using the Get-CimInstance or Get-WmiObject cmdlets with the Win32_Service class. The good news is that every Read more [...]

An Uncommon Cause for IIS 503 Service Unavailable Errors

Recently, while migrating IIS websites to a new server, I encountered "Service Unavailable HTTP Error 503. The service is unavailable." errors, but only for HTTPS, while HTTP worked fine. Depending on the scenario, the problem could have just as easily impacted HTTP. The server was listening on port 443: If you ever encounter a problem like this, stop the web publishing service: Then check to see if the server is Read more [...]

Access Local Variables in a Remote Session with PowerShell

Occasionally I'll come across a system with PowerShell version 2.0 on it that I need to run a remote command against which needs access to local variables. I can never remember how to accomplish that task so I thought I would write a blog about it as a reminder for myself and others who may find themselves in the same scenario. I'll demonstrate each of the available options and whether or not they work on PowerShell version 5.1 And PowerShell version 2.0 First, Read more [...]

Safety to prevent entire script from running in the PowerShell ISE

I recently watched fellow Microsoft MVP Thomas Rayner present a session on regular expressions for the MVP Days virtual conference. Sometimes it's the little things that are the biggest takeaways for me when I'm watching others present. One thing that wasn't related to regular expressions that I noticed was Thomas's way of preventing his entire script from running if F5 was accidentally pressed instead of F8 in the PowerShell ISE (Integrated Scripting Environment). If you're not aware, F5 runs the Read more [...]

Registration for the PowerShell & DevOps Global Summit 2018

Registration for the PowerShell & DevOps Global Summit 2018 opens on Wednesday, November 1st which is less than one week away. I've attended every one of these conferences that have been held in North America since its inception 5 years ago. I speak from experience when I say now is the time to ask for approval to attend this conference because it has sold out each year and it's not a matter of if it will sell out, but when will it sell out? The event brochure has lots of great information Read more [...]

Configure Internet Connection Sharing with PowerShell

My test environment runs as Hyper-V VM's on my IBM Thinkpad P50. I use ICS (Internet Connection Sharing) to shield my Hyper-V test environment virtual network from my production network connection. ICS allows me to temporarily give my test VM's Internet access when needed without putting them directly on the production network. You might ask why? Because my test environment VM's run things like DHCP servers that would cause havoc on the production network. I use an Internal virtual switch with Hyper-V Read more [...]

Windows Server 2016 Automation with PowerShell Cookbook – Second Edition

One of the projects that I've been a part of this year that's now complete is Windows Server 2016 Automation with PowerShell Cookbook - Second Edition written by Thomas Lee and published by Packt Publishing. I personally read each and every page of the book while it was being written along with testing every single line of code in each of the recipes in the book. According to the book's webpage on the Packt Publishing website, it has more than a hundred recipes and we're not talking about one-liners. While Read more [...]

Presenting The No-Nonsense Beginner’s Guide to PowerShell for the Austin PowerShell User Group on October 5th

If you’re interested in some free PowerShell training where you’ll learn the basics of PowerShell from a best practices standpoint, I’ll be presenting a session on “PowerShell 101: The No-Nonsense Beginner’s Guide to PowerShell” for the Austin PowerShell User Group this Thursday, October 5th. The presentation begins at 6pm central time and is a beginner level session. Here’s a little information about what you can expect from the presentation: Interested in PowerShell but Read more [...]

Regions now available in VSCode Insiders Build version 1.17.0

Today, David Wilson from the PowerShell team at Microsoft, announced that Regions are now available in VSCode (Visual Studio Code) as of insiders build version 1.17.0. I was hoping the region and endregion keywords would be case-insensitive unlike in the PowerShell ISE where they're case-sensitive. It looks like that's indeed what they intended since the region keyword is case-insensitive in VSCode, but unfortunately the endregion keyword is case-sensitive as shown in the following example. There's Read more [...]

PowerShell Toolmaking session this Saturday, September 30th at Gulf Coast Code Camp 2017 in Mobile, Alabama

Got no training budget? This Saturday, September 30th, is your opportunity to show some initiative by leveling up your skills on your own time and at your own expense (it's free) at Gulf Coast Code Camp 2017. The venue is at the University of South Alabama and features 16 speakers who are experts in the technology space. While I can't speak for everyone else who is presenting, my session begins at 9:40am central time where you'll learn the industry's best practices for PowerShell Toolmaking with Read more [...]

Not Specifying a Verb in PowerShell is an Expensive Shortcut

When working with PowerShell, there are lots of shortcuts that can be taken and while some of them may seem like a good idea at first, they usually end up costing you more trouble than they're worth in the long run. I recently saw a Tweet that a fellow PowerShell enthusiast Tore Groneng‏ responded to which referenced running commands in PowerShell without specifying a verb. Such as "Service" for Get-Service. That works great, right? Not so fast. It might Read more [...]

Detect the presence of and remove CCleaner with PowerShell

Based on the news today, I thought I would share a couple of PowerShell code snippets to detect the presence of and silently uninstall CCleaner. You can detect the presence of CCleaner along with the version of it you have installed via the registry. You can use a similar command to run its uninstaller silently if it's detected. Give it a couple of minutes and then run the first command again to verify it has been removed. If Read more [...]

PowerShell Version 2 Compatible Function to Determine Windows Firewall State

I recently had a need to perform some security auditing on an environment that still has some servers running PowerShell version 2 (PowerShell version 2 is deprecated). One of the things I needed to determine was whether or not the Windows firewall was enabled on each of the servers in the environment. Luckily, all of the servers at least had PowerShell remoting enabled. The PowerShell function shown in the previous code example is a wrapper for the Netsh.exe command. Read more [...]

Remotely cleanup log and temp files from your Windows based servers with PowerShell

Setting up a scheduled task or job on individual servers to cleanup log and temp files just doesn't scale very well because you have scheduled tasks or jobs setup on lots of individual servers that need to be maintained. Today it's this server and tomorrow it's two or three more. It's much easier to setup one scheduled task or job on a server that's designed for management to remotely cleanup the desired files on all of your servers. The following log and temp file cleanup script is provided as Read more [...]