Windows PowerShell has been proven to be a strong automation tool that has various usages for IT professionals as well as developers. This object-based scripting language became part of many Microsoft servers and development tools. The enhanced .NET integration along with the new web cmdlets in Windows PowerShell 4.0 made it a developer-friendly tool.
Windows PowerShell 4.0 for .NET Developers comes with a set of easy-to-follow practical examples and real-world scenarios that will help you in getting started with PowerShell, understanding the syntax and grammar, building your scripts and modules, and integrating them with different technologies and tools.
This guide starts with the essential topics of PowerShell along with new features in PowerShell 4.0, then goes through building scripts and modules, and then goes deep into integration topics. Next, it covers PowerShell integration with .NET, WMI, and COM.
Moreover, we will use PowerShell to manage Windows Server, Internet Information Services, SQL Server, and Team Foundation Server. Finally, we will be working with XML and RESTful web services.
Chapter 1, Getting Started with Windows PowerShell, introduces us to Windows PowerShell and the new features in Version 4.0. It also introduces us to the difference between PowerShell, other command-line tools, and programming languages. Also, it covers the syntax fundamentals and grammar of the language.
Chapter 2, Unleashing Your Development Skills with PowerShell, demonstrates both simple and advanced examples of how to make use of PowerShell integration with technologies such as .NET, WMI, CIM, and COM. It also covers extending Windows PowerShell's capabilities for writing scripts and building modules.
Chapter 3, PowerShell for Your Daily Administration Tasks, focuses on using Windows PowerShell with different technologies and tools that you might use on a daily basis, such as Windows Server, SQL Server, and Internet Information Services.
Chapter 4, PowerShell and Web Technologies, focuses on unveiling the hidden power of PowerShell cmdlets to work with web technologies, including but not limited to web services, RESTful applications, and social networking.
Chapter 5, PowerShell and Team Foundation Server, provides instructions on how to use PowerShell to work with Visual Studio Team Foundation Server for more productive and effortless automated application lifecycle management.
This book requires you to have Windows PowerShell 4.0, which is available out of the box in Windows Server 2012 R2 and Windows 8.1. It is also available for earlier versions of Windows as a part of Microsoft Windows Management Framework (WMF) Version 4.0.
This book is mainly about using Windows PowerShell with different technologies and tools, so you must have the following software in order to proceed:
Windows Server 2012 R2
SQL Server 2012
Visual Studio 2012/2013
Visual Studio Team Foundation Server 2012/2013
This book is intended for the .NET developers who are willing to learn Windows PowerShell and want to quickly come up on discovering Windows PowerShell and its capabilities with different tools and technologies.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You can get this path within your PowerShell by using a predefined variable called $PSHome
."
A block of code is set as follows:
Function Reload-Module($ModuleName) { if((get-module -list | where{$_.name -eq "$ModuleName"} | measure-object).count -gt 0) { if((get-module -all | where{$_.Name -eq "$ModuleName"} | measure-object).count -gt 0) { Remove-Module $ModuleName Write-Host "Module $ModuleName Unloading" } Import-Module $ModuleName Write-Host "Module $ModuleName Loaded" } Else { Write-Host "Module $ModuleName Doesn't Exist" } }
Any command-line input or output is written as follows:
PS C:\> Get-CimInstance -Query $Query | Select DeviceID, Name DeviceID Name -------- ---- 0 Intel(R) 82579LM Gigabit Network Connection 2 Intel(R) Centrino(R) Ultimate-N 6300 AGN
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen."
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>
, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.