Learn PowerShell Core 6.0

Book description

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.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Learn PowerShell Core 6.0
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the authors
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Current PowerShell Versions
    1. Technical requirements
    2. Historical background
    3. Overview of different versions of Powershell
      1. PowerShell Editions 
    4. Windows PowerShell 5.1
    5. PowerShell Core 6
    6. PowerShell Open Source
      1. Downloading the source code
      2. Developing and contributing
    7. The goals of PowerShell Core 6
      1. Dependencies and support
      2. Compatibility
      3. Cross-platform remoting
    8. Azure Cloud Shell
      1. Features of PowerShell in Cloud Shell
    9. Future of PowerShell
    10. Summary
    11. Questions
    12. Further reading
  8. PowerShell ISE Versus VSCode
    1. Introduction to currently available tools
      1. Recap
    2. PowerShell ISE
    3. Visual Studio Code
      1. Introduction
      2. Download
      3. Installation
      4. First start
      5. Basics
    4. ISE versus VSCode
    5. Summary
    6. Questions
    7. Further reading
  9. Basic Coding Techniques
    1. Comments
    2. Regions
    3. Types
    4. Variables
    5. Commands and parameters
      1. Approved verb list
    6. PSDrives and PSProviders
    7. PowerShell's scripting language
      1. Script blocks
      2. Operators
        1. Pipeline operator
        2. Type operators
        3. Arithmetic operators
        4. Assignment operators
        5. Comparison operators 
        6. Logical operators
        7. Split and join operators
        8. Bitwise logical operators
        9. Replace operator
        10. Unary operators
      3. Language constructs
        1. Indentation
        2. If...ElseIf, and Else
        3. Switch
        4. Loops
        5. for loop
        6. do loop
        7. while loop
        8. foreach loop
        9. break and continue loops
    8. Error handling
      1. Non-terminating
      2. Terminating errors
    9. Remoting
      1. Types of remoting
    10. Summary
    11. Questions
    12. Further reading
  10. Advanced Coding Techniques
    1. Technical requirements
    2. Working with credentials
    3. Working with external utilities
    4. Pipeline and performance
      1. Performance
      2. Parallel execution
    5. Working with APIs
      1. Creating a REST endpoint
        1. Create
        2. Read
        3. Update
        4. Delete
      2. Interacting with a RESTful API
    6. Working with events
      1. Object events
      2. WMI events
      3. Engine events
      4. Remote events
    7. Custom formatting
    8. Custom type extensions
    9. Summary
    10. Questions
    11. Further reading
  11. Writing Reusable Code
    1. Best practice guidelines
      1. Code layout
        1. Brace placement
        2. Naming conventions
        3. Aliases and parameter names
        4. Readability
        5. Function design
      2. Output
        1. Cmdlet output
        2. Conveying messages
      3. Compatibility
      4. Comments
      5. Header or disclaimer
    2. Functions
      1. Script blocks
      2. Function declaration
      3. The parameter attribute
        1. Parameter sets
        2. Pipeline input
      4. Cmdlet binding attribute
      5. Scopes
        1. Dot-sourcing code
    3. Help files
      1. Help-driven development
    4. Code signing
      1. Possible solutions
        1. Digital certificates
        2. Public key Infrastructure
        3. Self-signed certificates for testing
      2. Preventing changes and execution
      3. Proving that changes were made
    5. Modules
      1. Module architecture
      2. Combining multiple functions
        1. The module manifest
      3. Managing complexity
      4. Deployment and upgrade
    6. Version control
      1. Changelog
      2. Recovery
        1. Revert
        2. Checkout
        3. Reset
      3. Branching
      4. Merging
      5. Possible solutions
        1. TFS
        2. Git
        3. SVN
    7. PSScriptAnalyzer
    8. Summary
    9. Questions
    10. Further reading
  12. Working with Data
    1. Registry
    2. Files
    3. CSV
    4. XML
    5. CLIXML
    6. JSON
    7. Classes 
    8. Summary
    9. Questions
    10. Further reading
  13. Understanding PowerShell Security
    1. Current situation around PowerShell
    2. Is PowerShell a vulnerability?
    3. Principle of Least Privilege
    4. The community
    5. Version 5
    6. Evergreen
    7. Secure coding
    8. Remoting
      1. Double hop 
    9. ExecutionPolicy
      1. Bypassing the ExecutionPolicy
    10. Executing PowerShell without PowerShell.exe
    11. Constrained language mode
    12.  AppLocker
      1. How the Constrained Language Mode is enforced
      2. Windows Defender Application Control
    13. Obfuscation
    14. Logging
    15. AMSI
    16. Prioritizing technical security controls
    17. Summary
    18. Questions
    19. Further reading
  14. Just Enough Administration
    1. Technical overview
    2. Session authoring
    3. Role capabilities
      1. Merging role capabilities
        1. Cmdlet visible in one role
        2. Cmdlet visible in multiple roles
        3. Validation is used in one role
        4. Validation is used in multiple roles
        5. ValidateSet and ValidatePattern are mixed
    4. Session configurations
      1. Language mode and session type
      2. Transcripts
      3. Accounts
        1. Connecting users
        2. Virtual account
        3. Group-managed service account
      4. User drive
    5. Deploying session configurations
      1. Individual activation
      2. Distributed activation
      3. Desired State Configuration
    6. Use cases
    7. Summary
    8. Questions
    9. Further reading
  15. DevOps with PowerShell
    1. What is DevOps?
      1. WinOps
      2. DevSecOps
    2. Why DevOps
      1. Traceability
      2. Reliability
      3. Speed
    3. Test-driven development
    4. Continuous integration
    5. Continuous deployment
    6. Challenges of DevOps
    7. The value of PowerShell
    8. Summary
    9. Questions
    10. Further reading
  16. Creating Your Own PowerShell Repository
    1. Package management
      1. Centralization
      2. Interacting with repositories
    2. Knowledge management
      1. Documentation with PlatyPS
    3. PowerShell repository
      1. Setup
      2. Modules
      3. Signing
      4. Version control
      5. PowerShellGet
    4. Execution
      1. Dedicated user
      2. JEA
    5. Deploying and upgrading
      1. PowerShellGet
      2. End user updates
      3. Automatic updates
      4. JEA servers
    6. Summary
    7. Questions
    8. Further reading
  17. VSCode and PowerShell Release Pipelines
    1. Configuration
      1. Interface
    2. Extensibility
    3. Preparing for a release pipeline
    4. Working with different hosts
    5. Plaster
      1. Creating templates
      2. Packaging templates
    6. PSScriptAnalyzer
    7. Pester
      1. Mock
        1. Mock .NET calls
      2. Describe
      3. Context
      4. It
      5. Running tests
    8. Git
      1. Centralized workflow
      2. Forking workflow
    9. CI tools
    10. Bringing it all together
    11. Summary
    12. Questions
    13. Further reading
  18. PowerShell Desired State Configuration
    1. Introducing DSC
      1. Why Desired State Configuration?
      2. Configurations
    2. Local Configuration Manager – LCM
    3. Push
      1. When to use
    4. Pull
      1. When to use
    5. Security
    6. Resources
      1. Built-in resources
      2. Community
      3. Custom
      4. Composite
    7. DSC Core
    8. Summary
    9. Questions
    10. Further reading
  19. Working with Windows
    1. Retrieving the latest PowerShell version
    2. WMI CIM
    3. Delivery Optimization
    4. Retrieving all log events and files for update issues
    5. Turning off energy-saving mechanisms
    6. Verifying installed updates
    7. Working with apps
    8. EventLog
    9. ETL parsing
    10. Convert-PPTX to PDF
    11. Summary
    12. Questions
    13. Further reading
  20. Working with Azure
    1. Azure 101
      1. Resource groups
      2. Tags
      3. Resources
    2. PowerShell in Azure Cloud Shell
      1. The Azure drive
    3. Resource group deployment
      1. Finding templates
      2. Resources
      3. Parameters and variables
      4. Functions in templates
    4. Individual deployments
    5. Summary
    6. Questions
    7. Further reading
  21. Connecting to Microsoft Online Services
    1. Office 365
    2. Exchange Online
      1. Using some cmdlets
    3. SharePoint Online
    4. Microsoft Teams
    5. Summary
    6. Questions
    7. Further reading
  22. Working with SCCM and SQL Server
    1. System Center Configuration Manager
      1. Logging
      2. PowerShell App Deployment Toolkit
    2. SQL Server
      1. Working with the SqlServer module
        1. The SQL Provider
        2. Connecting to SQL instances
        3. Running manual queries
        4. Working with availability groups
        5. Masterkeys, encryption, and credentials
      2. Working with the dbatools module
        1. Discovering SQL instances
        2. Connecting to SQL instances – the SqlInstance parameter
        3. Running manual queries
        4. PowerShell to SQL
        5. Navigating the module
        6. Backup, restore, and test
        7. Deploying maintenance insight tools
        8. Migrations made easy
      3. Working with the Reporting Services module
        1. Connecting to the Reporting Services server
          1. Administrating the service
          2. Managing the data in the service
        2. Working with content
          1. Navigating the structure
          2. Exporting content
          3. Importing content
        3. Configuring SSRS servers
      4. Working with the dbachecks module
        1. Configuration
        2. Feel the power
    3. Summary
    4. Questions
  23. PowerShell Deep Dives
    1. Creating XAML GUIs with PSGUI
    2. Scalable DSC configuration
      1. The problem
      2. The setup
      3. Configuration data
      4. Configurations
      5. Build
    3. ConvertFrom-String
    4. LINQ
    5. OpenFileDialog
    6. Username to Security Identifier (SID)
    7. SHiPS
    8. PSDefaultParameterValues and PSBoundParameters
      1. PSDefaultParameterValues
      2. PSBoundParameters
    9. ConvertTo-Breakpoint
    10. Summary
    11. Questions
    12. Further reading
  24. PowerShell ISE Hotkeys
    1. Keyboard shortcuts for editing text
      1. Keyboard shortcuts for running scripts
      2. Keyboard shortcuts for customizing the view
      3. Keyboard shortcuts for debugging scripts
      4. Keyboard shortcuts for Windows PowerShell tabs
      5. Keyboard shortcuts for starting and exiting
    2. References
    3. VSCode Hotkeys
      1. Default keyboard shortcuts
        1. Basic editing
        2. Rich languages editing
        3. Navigation
        4. Editor/Window management
        5. File management
        6. Display
        7. Search
        8. Preferences
        9. Debug
        10. Tasks
        11. Extensions
    4. References
  25. Assessments
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 8
    9. Chapter 9
    10. Chapter 10
    11. Chapter 11
    12. Chapter 12
    13. Chapter 13
    14. Chapter 14
    15. Chapter 15
    16. Chapter 16
    17. Chapter 17
  26. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Learn PowerShell Core 6.0
  • Author(s): David das Neves, Jan-Hendrik Peters
  • Release date: July 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788838986