PowerShell Version 5 New Feature: NoWait Parameter added to Stop-Service

I presented a session on “What’s New in PowerShell Version 5?” at TechStravaganza in Atlanta this past Friday and there was a lot of information I wasn’t able to get to because of the massive amount of information that I’ve compiled about the updates to PowerShell version 5 that are in the May 2014 preview version so I thought I would blog about them.

He’s a picture of me presenting at TechStravaganza in Atlanta this past Friday. The event was held at the Georgia Tech Research Institute Conference Center:

mikefrobbins-speaking-at-georgia-tech

They must have known I was going to speak on PowerShell as the wording at the bottom of the plaque on the podium says “Problem Solved” as shown in the previous image (click on the image for a larger view).

One of the new features is that Stop-Service now has a NoWait parameter. When you stop a service that doesn’t immediately stop, by default a warning is received stating that in this example: “WARNING: Waiting for service ‘IIS Admin Service (IISAdmin)’ to stop…”:

ps5-nowait1

With this new NoWait parameter, your prompt is returned back to you immediately:

ps5-nowait2

Notice that in the previous example, specifying the PassThru parameter didn’t cause any results to be returned when used with the NoWait parameter. This leads me to believe that these two parameters will end up being in mutually exclusive parameter sets in the final release version.

To give you a better idea of what’s going on under the covers, I’ll stop the service specifying the NoWait parameter and then immediately get the status of the service with the Get-Service cmdlet. I typically wouldn’t use the Format-Table cmdlet in this scenario, but without the AutoSize parameter the value of the Status property is truncated:

ps5-nowait3

This blog article has been written based on the preview version of PowerShell version 5 from the May 2014 release of the Windows Management Framework 5.0 preview so what you’ve seen here is subject to change in the final release version.

This blog article is one of many that I’ve written and will be writing about the new features in PowerShell version 5. You can find my other blog articles on PowerShell version 5 here.

µ

About Mike Robbins

PowerShell Enthusiast | IT Pro | Winner of the Advanced Category in the 2013 PowerShell Scripting Games | Author of Chapter 6 in the PowerShell Deep Dives Book.
This entry was posted in PowerShell and tagged , . Bookmark the permalink.

One Response to PowerShell Version 5 New Feature: NoWait Parameter added to Stop-Service

  1. Pingback: PowerShell Version 5 New Feature: SkipLast Parameter added to Select-Object | Mike F Robbins

Leave a Reply