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.4. Implementing ShouldProcess

For our next tool, we’re going to change a service’s logon password. This is something that must be accomplished by running the Change() method of WMI’s Win32_Service class. Glancing at the MSDN documentation for the class (http://msdn.microsoft.com/en-us/library/windows/desktop/aa384901(v=vs.85).aspx), we see that the Change() method accepts numerous settings. The eighth one sets the logon password, so we’ll need to pass $null for the first seven parameters, so that we don’t change any of them. We can omit the ninth and subsequent parameters, because we also don’t want to change them. Again, we’ll start by testing this in the shell—we’ll modify the BITS service, because doing so won’t mess up anything too severely. ...

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