PowerShell for Developers
Join the DZone community and get the full member experience.Join For Free
powershell was written first and foremost for windows system administrators, and the benefits to this community are clear. it’s not as clear what developers should make of powershell.
administrators can learn powershell as a shell first , and gradually transition from interactive use to scripting. they may learn powershell as their first programming language and not even give too much thought to the language per se. but a developer has to ask why and when to use powershell rather than another language, such as c#.
doug finke’s new book windows powershell for developers is “for developers” in a couple ways. first, the style of the book is geared toward developers. the book is small, less than 200 pages, because the author assumes the readers are experienced windows developers who want to focus on what powershell adds to what they already know. second, the book focuses on tasks a developer might want to do. rather than show you how to create a new active directory user, as many powershell books would, this book covers topics such as
- code generation
- static analysis
- interfacing with c#
- embedding powershell in your application
- working with xml and json
- interfacing with excel
- creating dsls.
so why should software developers use powershell? and what tasks should they do in powershell? one answer to the first question, implicit in the book’s examples, is that powershell makes it possible to carry out common tasks with little code. another answer explicitly given in the book is integration.
given powershell’s growing integration with the rest of the windows platform, as powershell grows, so does your application .”
the book is full of examples of what tasks a developer might want to do in powershell. the examples i found most interesting were embedding powershell to provide a scripting language for your application and creating dsls in powershell.
one pattern in the examples is text munging, whether that text is source code or common data file formats. another pattern is integration, especially integrating microsoft technologies. powershell is designed to make it possible to solve these kinds of problems with a minimum of ceremony.
i’ll close with a couple reasons why might a developer not want to use powershell in my opinion. the first is frequency of use. although powershell can solve many problems with significantly less code than c# would require, you have to learn powershell first, and you have to use it frequently enough to remember it. you have to use powershell enough to repay the time invested in learning and practicing it.
the second reason is size. the c# language and the visual studio ide were designed for large projects, but scale down fairly well for smaller projects. powershell was designed for the command line, but scales fairly well for large scripts. if you use powershell and c#, you’ll have to decide at what size you want to switch from one language to the other.
Published at DZone with permission of John Cook, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.