Tag: PowerShell

The PowerShell Iron Scripter: My solution to prequel puzzle 1

Each week leading up to the PowerShell + DevOps Global Summit 2018, PowerShell.org will be posting an iron scripter prequel puzzle on their website. As their website states, think of the iron scripter as the successor to the scripting games. I've taken a look at the different factions and it was a difficult choice for me to choose between the Daybreak and Flawless faction. While I try to write code that's flawless, perfection is in the eye of the beholder and it's also a never-ending moving target. Read more [...]

Use PowerShell to create a bootable USB drive from a Windows 10 or Windows Server 2016 ISO

It seems as if every time I need to reload a physical system, I'm searching the Internet to find a way to create a bootable USB drive from a Windows 10 or Windows Server 2016 ISO. I always seem to find tutorials that are using a process that's almost 20 years old. They have me using the diskpart command line utility. Diskpart which initially shipped with Windows 2000, reminds me way too much of its predecessor, the fdisk command line utility. The PowerShell commands in this blog article are written Read more [...]

PowerShell Compare-Object doesn’t handle null values

I thought I'd run into a bug with the Compare-Object cmdlet in PowerShell version 5.1 earlier today. Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it is null. At line:1 char:33 + Compare-Object -ReferenceObject $DriveLetters -DifferenceObject $Driv ... + ~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Compare-Object], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.CompareObjectCommand Running Read more [...]

PowerShell 101: The No-Nonsense Beginner’s Guide to PowerShell is the featured book on Leanpub

Learning PowerShell seems to be a hot topic for the new year. My PowerShell 101 book was the number one bestseller on Leanpub earlier this week and now it's the featured book on their website. Going to the homepage on their website, shows the book is indeed the currently featured one. I would also like to thank Tommy Maynard for the technical editing he performed on the book. If you're not following him on Twitter or reading the articles on his blog site, you should be. µ Read more [...]

Using PowerShell to Check Remote Windows Systems for CVE-2017-5754 (Meltdown) and CVE-2017-5715 (Spectre)

The Microsoft Security Response Center has released a PowerShell module named SpeculationControl that can be used to check for the CVE-2017-5754 (Meltdown) and CVE-2017-5715 (Spectre) vulnerabilities. The SpeculationControl module can be installed from the PowerShell Gallery with Install-Module which is part of the PowerShellGet module that ships natively with PowerShell version 5.0, but can be installed on PowerShell version 3.0 and higher. Running Read more [...]

Learn to write award winning PowerShell functions at SQL Saturday Nashville on January 13th

Interested in learning how to write PowerShell functions that follow industry standard best practices? Well, you're in luck. I'll be presenting a session on "Writing award winning PowerShell functions and script modules" at SQL Saturday #698 in Nashville, Tennessee on January 13th. In addition to my session, there are a number of PowerShell sessions throughout the day so be sure to check the schedule. Here's a little about what you can expect from my presentation: "Transitioning from Read more [...]

PowerShell 101: The No-Nonsense Beginner’s Guide to PowerShell is the number one bestseller on Leanpub

I would like to thank everyone who helped make my new book, PowerShell 101: The No-Nonsense Beginner’s Guide to PowerShell, the number one bestseller on Leanpub.com. As shown in the previous image, PowerShell 101 is the number one top book on their homepage. It's also the number one bestseller on their site in the last week: And the book with the most copies sold in the last week: Today is the last day to purchase the book using the special year's end promotion, but as always with Read more [...]

My new PowerShell book is on sale for 99-cents until the end of the year!

On Christmas day, I announced that my new book, PowerShell 101: The No-Nonsense Beginner’s Guide to PowerShell had been completed. I gave away 10 copies of it along with placing it on sale for 99-cents (reduced from the suggested price of $15.99) until the end of the year. Time is running out, but there's still time to grab a copy at this price. Use this URL to access the 99-cent sale. As always, with Leanpub.com, you can pay more. All of the proceeds from this book help keep this Read more [...]

Merry Christmas! I’m giving away 10 free copies of my PowerShell 101 book

Earlier this year, I announced that I would be writing a new book "PowerShell 101: The No-Nonsense Beginner’s Guide to PowerShell" that would be completed before the end of the year and published on Leanpub.com. As I wrote the chapters, I incremented the percentage complete on the book's webpage. A few days ago, I made a few final corrections and marked the book as being 100% complete. One thing that I'm a big believer in is do what you say you're going to do. I wanted to make sure the book Read more [...]

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 [...]