ebook img

Mastering Windows PowerShell Scripting PDF

428 Pages·2017·2.223 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Mastering Windows PowerShell Scripting

Mastering Windows PowerShell Scripting Second Edition One-stop guide to automating administrative tasks Chris Dent Brenton J.W. Blawat BIRMINGHAM - MUMBAI Mastering Windows PowerShell Scripting Second Edition Copyright © 2017 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: April 2015 Second edition: October 2017 Production reference: 1251017 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78712-630-5 www.packtpub.com Credits Authors Project Coordinator Chris Dent Kinjal Bari Brenton J.W. Blawat Reviewer Proofreader Paul Broadwith Safis Editing Acquisition Editor Indexer Meeta Rajani Tejal Daruwale Soni Content Development Editor Graphics Mamata Walkar Kirk D'penha Technical Editor Production Coordinator Varsha Shivhare Nilesh Mohite Copy Editors Safis Editing Ulka Manjrekar About the Authors Chris Dent is a professional PowerShell developer based in and around London with over 8 years experience in that language alone. He is also proficient in C#, VBScript, Perl, and Python, but PowerShell is his favorite by a wide margin. He is also the author of dnshell. He describes himself as being a toolset or module developer (he rarely writes scripts in the one-off sense); he has a deep interest in formalized development approaches, continuous integration, secure coding practices, and creating supportable automation frameworks within organizations. Brenton J.W. Blawat is an entrepreneur, strategic technical advisor, author, and enterprise architect, who has a passion for the procurement of technology in profit-based organizations. He is business-centric and technology-minded. Brenton has many years of experience in bridging the gap between technical staff and decision-makers in several organizations. He takes pride in his ability to effectively communicate with a diverse audience and provide strategic direction for large and small organizations alike. In 2013, Brenton authored his first book, PowerShell 3.0 WMI Starter, Packt Publishing. In March 2015, he authored his second book, Mastering Windows PowerShell Scripting, with Packt Publishing. Brenton currently works at CDW as an Enterprise Architect in strategic solutions and services. CDW is a leading multibrand technology solutions provider in the fields of business, government, education, and healthcare. A Fortune 500 company, it was founded in 1984 and employs approximately 7,200 coworkers. In 2016, the company generated net sales of more than $13.0 billion. His current specialization sits on top of 15 years of experience spread across (predominantly Microsoft) systems, (Juniper and Cisco) networking, and security. About the Reviewer Paul Broadwith is a senior technology professional freelancing in Scotland. He has over 25 years of experience in diverse sectors, from manufacturing and financial services to the public sector and managed IT services. With particular expertise in Microsoft and Linux technologies, he has interest in PowerShell on both platforms. An advocate of a common-sense approach to coding, best practice, and code reusability, he enjoys practicing what he preaches in his code and mentoring new professionals. www.PacktPub.com For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. https:/​/​www.​packtpub.​com/​mapt Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career. Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content On demand and accessible via a web browser Customer Feedback Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1787126307. If you'd like to join our team of regular reviewers, you can email us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products! Table of Contents Preface 1 Chapter 1: Introduction to PowerShell 6 What is PowerShell? 7 Quick reference 7 Comments 7 Special characters 7 Tick in PowerShell 7 Common operators 9 Dropping unwanted output 9 Creating arrays and hashtables 9 Strings 10 Common reserved variables 11 Quick commands and hot keys 12 PowerShell editors 12 PowerShell ISE 13 Features 14 Installing ISE Preview 14 Starting ISE 15 Visual Studio Code 15 Features 15 Console 16 Version control (Git) 18 PowerShell on Linux 19 Installing PowerShell 20 Where are the PowerShell files? 20 Changing the shell 21 Profiles 21 Multiplatform scripting 22 Line endings 23 File encoding 23 Path separator 24 Example 24 Summary 25 Chapter 2: Working with PowerShell 26 Getting help 26 Updatable help 27 The Get-Help command 28 Syntax 29 Examples 29 Parameter 30 Detailed and Full switches 30 Save-Help 31 Update-Help 32 About help files 33 Command naming and discovery 34 Verbs 34 Nouns 35 Finding commands 35 Aliases 36 Parameters and parameter sets 37 Parameters 37 Optional parameters 37 Optional positional parameters 38 Mandatory parameters 38 Mandatory positional parameters 38 Switch parameters 39 Common parameters 39 Parameter values 40 Parameter sets 41 Confirm, WhatIf, and Force 42 Confirm parameter 42 ConfirmPreference 43 WhatIf parameter 45 WhatIfPreference 45 Force parameter 46 Providers 46 Drives using providers 47 Using providers 49 Summary 51 Chapter 3: Modules and Snap-Ins 52 What is a module? 53 What is the PowerShell Gallery? 54 The Get-Module command 56 The Import-Module command 57 The Remove-Module command 58 The Find-Module command 59 The Install-Module command 59 [ ii ]

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.