Learn PowerShell Core 6.0
eBook - ePub

Learn PowerShell Core 6.0

Automate and control administrative tasks using DevOps principles

  1. 552 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learn PowerShell Core 6.0

Automate and control administrative tasks using DevOps principles

Book details
Book preview
Table of contents
Citations

About This Book

Enhance your skills in expert module development, deployment, security, DevOps, and cloud

Key Features

  • A step-by-step guide to get you started with PowerShell Core 6.0
  • Harness the capabilities of PowerShell Core 6.0 to perform simple to complex administration tasks
  • Learn core administrative concepts such as scripting, pipelines, and DSC

Book Description

Beginning with an overview of the different versions of PowerShell, Learn PowerShell Core 6.0 introduces you to VSCode and then dives into helping you understand the basic techniques in PowerShell scripting. You will cover advanced coding techniques, learn how to write reusable code as well as store and load data with PowerShell.

This book will help you understand PowerShell security and Just Enough Administration, enabling you to create your own PowerShell repository. The last set of chapters will guide you in setting up, configuring, and working with Release Pipelines in VSCode and VSTS, and help you understand PowerShell DSC. In addition to this, you will learn how to use PowerShell with Windows, Azure, Microsoft Online Services, SCCM, and SQL Server. The final chapter will provide you with some use cases and pro tips.

By the end of this book, you will be able to create professional reusable code using security insight and knowledge of working with PowerShell Core 6.0 and its most important capabilities.

What you will learn

  • Get to grips with Powershell Core 6.0
  • Explore basic and advanced PowerShell scripting techniques
  • Get to grips with Windows PowerShell Security
  • Work with centralization and DevOps with PowerShell
  • Implement PowerShell in your organization through real-life examples
  • Learn to create GUIs and use DSC in production

Who this book is for

If you are a Windows administrator or a DevOps user who wants to leverage PowerShell to automate simple to complex tasks, then this book is for you. Whether you know nothing about PowerShell or just enough to get by, this guide will give you what you need to go to take your scripting to the next level. You'll also find this book useful if you're a PowerShell expert looking to expand your knowledge in areas such as PowerShell Security and DevOps.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Learn PowerShell Core 6.0 by David das Neves, Jan-Hendrik Peters in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Networking. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781788835473
Edition
1

Basic Coding Techniques

In this chapter, you'll learn about the basics in PowerShell scripting, which are necessary to develop and understand most PowerShell scripts. We recommend using VSCode when working with the examples provided in this and all subsequent chapters. We put forth our argument in its favor in the previous chapter and the examples assume they are run in the editor's console. You can download the code from GitHub to work with the provided examples; you can find them at https://github.com/ddneves/Book_Learn_PowerShell.
Keep in mind that you should put a lot of efforts into training yourself with the content of this chapter, because it is the foundation for upcoming chapters. Some of the topics are simply introduced and will be expanded upon in upcoming chapters, providing the best didactic methods.
In this chapter, we will cover the following topics:
  • Comments
  • Regions
  • Types
  • Pipelines
  • Commands and parameters
  • PSDrives and PSProviders
  • PowerShell's scripting language:
    • Operators
    • Loops
    • Break and Continue
    • If...ElseIf...Else
    • Switch

Comments

I'd like to introduce comments right at the beginning. As you may know (from other scripting or coding languages), comments are necessary to describe and explain your code. Developers often argue that code is self-explanatory, but that is a lie. You will quickly learn that, even when working with your own scripts, it is always good to have some comments on the side. You can use either line comments or comment blocks in PowerShell, which make use of the key character (#), and look as follows:
# this is a comment line
## this as well

<#
this is a comment block
#>

<# this as well
this as well
this as well
#>
As we are starting with the basics, you should know that there are some best practices for writing code. We will provide many of them throughout this book, but the most important one is to always provide comments with your code, to help the reader, other coders, or even yourself, if you need to reuse or debug your code. If you need to write multiline comments, you can use comment blocks. For most of the other scenarios, line comments fulfill the job. Later on, you will see other commenting techniques, and how they can be valuable.

Regions

Regions are used to structure your code and give parts of the code separated names. Regions are special comments in your scripts that can be used to give structure to your code:
Regions are always initiated with the #region keyword followed by the title. You can also use a multi-word title, and nest as many regions as you want. In Visual Studio Code, you will also be able to collapse complete regions, to get a better overview. Just move the mouse cursor onto the left side of the opened region, and it will show you all possible collapse options, as visible in the previous screenshot. You can also fold all of the ...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Dedication
  4. Packt Upsell
  5. Contributors
  6. Preface
  7. Current PowerShell Versions
  8. PowerShell ISE Versus VSCode
  9. Basic Coding Techniques
  10. Advanced Coding Techniques
  11. Writing Reusable Code
  12. Working with Data
  13. Understanding PowerShell Security
  14. Just Enough Administration
  15. DevOps with PowerShell
  16. Creating Your Own PowerShell Repository
  17. VSCode and PowerShell Release Pipelines
  18. PowerShell Desired State Configuration
  19. Working with Windows
  20. Working with Azure
  21. Connecting to Microsoft Online Services
  22. Working with SCCM and SQL Server
  23. PowerShell Deep Dives
  24. PowerShell ISE Hotkeys
  25. Assessments
  26. Other Books You May Enjoy