O'Reilly logo

Learn PowerShell Toolmaking in a Month of Lunches by Don Jones and Jeffrey Hicks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.2. Passthrough ShouldProcess

We’re going to create a tool called Restart-MOLCimComputer. Our tool will accept one or more computer names and will utilize WMI to restart them. Specifically, we’re going to use the Reboot() method of the Win32_OperatingSystem class. This method accepts no parameters; it simply begins the reboot.

 

Note

We’re aware that a very similar Restart-Computer command exists natively in PowerShell. Our technique will utilize PowerShell v3’s CIM cmdlet family, which utilizes the WS-MAN remoting protocol, rather than whatever black magic Restart-Computer uses to communicate. In addition, we needed a straightforward example, and this is what we thought of!

 

Anytime we start building a tool, we tend to start in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required