PowerShell 7 Workshop Learn How to Program with PowerShell 7 on Windows, Linux, and the Raspberry Pi
Exercises -- Further reading -- Chapter 5: PowerShell Control Flow - Conditionals and Loops -- An introduction to IDEs and VS Code -- Installing VS Code -- Configuring VS Code for PowerShell -- Conditional control - if, else, elseif, and switch -- The if statement -- The switch statement -- Loops -...
Otros Autores: | |
---|---|
Formato: | Libro electrónico |
Idioma: | Inglés |
Publicado: |
Birmingham, England :
Packt Publishing
[2024]
|
Edición: | First edition |
Materias: | |
Ver en Biblioteca Universitat Ramon Llull: | https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009805127806719 |
Tabla de Contenidos:
- Cover
- Title Page
- Copyright and Credits
- Contributors
- Table of Contents
- Preface
- Part 1: PowerShell Fundamentals
- Chapter 1: Introduction to PowerShell 7 - What It Is and How to Get It
- Technical requirements
- What is PowerShell 7?
- What is PowerShell 7 used for?
- Scripting languages versus system programming languages
- Getting PowerShell 7
- Installation from an .msi file
- Installation from the .zip file
- Installation with winget
- Other ways to install
- Running PowerShell 7
- Running PowerShell with administrator privileges
- Autocomplete
- Getting help
- Get-Command
- Get-Help
- Get-Member
- Summary
- Exercises
- Further reading
- Chapter 2: Exploring PowerShell Cmdlets and Syntax
- Technical requirements
- What are cmdlets?
- Exploring cmdlet structure
- The correct use of aliases
- Understanding cmdlet syntax
- How to find more cmdlets
- Finding modules and cmdlets on your machine
- Finding new modules and cmdlets
- Working interactively with PowerShell
- Windows Terminal - an alternative terminal emulator
- Installing Windows Terminal from Microsoft Store
- Summary
- Exercises
- Chapter 3: The PowerShell Pipeline - How to String Cmdlets Together
- How to bring cmdlets together - the pipeline
- What is an object?
- Selecting and sorting objects
- Using Select-Object
- Ordering objects with Sort-Object
- Filtering objects
- Understanding comparison operators
- Understanding Where-Object advanced syntax
- Multiple filters in the advanced syntax
- Filter optimization
- Enumerating objects
- Parallel enumeration
- How the pipeline works - parameter binding
- Understanding ByValue parameter binding
- ByPropertyName parameter binding
- Troubleshooting the pipeline - pipeline tracing
- Summary
- Exercises
- Further reading.
- Chapter 4: PowerShell Variables and Data Structures
- Understanding PowerShell variables
- Variables are not their contents
- Naming variables
- The three common types of PowerShell variable
- Exploring object types
- What is an object? - redux
- Discovering value types
- Booleans
- Integers
- Real numbers
- Char
- Typing explained
- Dynamic versus static typing
- Casting variables
- Navigating reference types
- Arrays
- Strings
- Hashtables
- Splatting - a cool use for hashtables
- Summary
- Exercises
- Further reading
- Chapter 5: PowerShell Control Flow - Conditionals and Loops
- An introduction to IDEs and VS Code
- Installing VS Code
- Configuring VS Code for PowerShell
- Conditional control - if, else, elseif, and switch
- The if statement
- The switch statement
- Loops - foreach, do while, do until, while, for
- The foreach loop statement
- The do while and do until loop statements
- The while loop
- The for loop
- Breaking and continuing
- The break statement
- The continue statement
- Let's play a game
- Summary
- Exercises
- Further reading
- Chapter 6: PowerShell and Files - Reading, Writing, and Manipulating Data
- Understanding formatting
- Format-List
- Format-Table
- Format-Wide
- Formatting gotchas
- Writing a text file
- Using ConvertTo- and Export- cmdlets
- CSV
- XML
- HTML
- Handling files
- A brief note about PSProviders and PSDrives
- Item- cmdlets
- Working with files
- Get-Content
- Import- cmdlets
- Let's have some fun - measuring the most frequent words in a text file
- Summary
- Exercises
- Further reading
- Chapter 7: PowerShell and the Web - HTTP, REST, and JSON
- Working with HTTP
- Why don't we see Forms information in PowerShell 7?
- Authentication
- Getting to grips with APIs
- RPC APIs
- SOAP APIs
- REST APIs
- WebSocket APIs.
- Working with REST
- Invoke-RestMethod
- Working with JSON
- ConvertFrom-Json
- ConvertTo-Json
- Test-Json
- Let's have some fun - who is on the International Space Station?
- Summary
- Exercises
- Further reading
- Part 2: Scripting and Toolmaking
- Chapter 8: Writing Our First Script - Turning Simple Cmdlets into Reusable Code
- Introduction to scripting
- Why do we want to write scripts?
- Getting scripts
- Running scripts
- Writing a script
- Identifying changing values
- Working with parameters
- Creating useful parameters
- Specifying type
- Making parameters mandatory
- Taking values from the pipeline
- Switch parameters
- Providing help for our script
- Comments
- Comment-based help
- Write-Verbose
- Parameter help messages
- Summary
- Further reading
- Exercises
- Chapter 9: Don't Repeat Yourself - Functions and Scriptblocks
- Why do we care about repeating code?
- How to turn repeating code into a function
- What makes a function?
- Function parameters
- Filters
- The concept of scope
- Parent and child scopes
- Scope modifiers
- Exploring scriptblocks
- How to run a scriptblock
- Lambdas
- Let's do something useful
- Summary
- Further reading
- Exercises
- Chapter 10: Error Handling - Oh No! It's Gone Wrong!
- What is an error?
- Terminating and non-terminating exceptions and errors
- Understanding error actions
- The ErrorActionPreference variable
- The -ErrorAction parameter
- Catching errors
- Try/Catch/Finally
- Creating errors
- Exploring debugging
- Script instrumentation
- Debugging cmdlets
- Debugging with VS Code
- Summary
- Exercises
- Further reading
- Chapter 11: Creating Our First Module
- Working with modules
- Module locations
- Module autoloading
- Importing modules
- PowerShellGet
- Writing a simple module
- A word of caution - dot-sourcing.
- Turning a script into a module
- Nested modules
- More modules
- Module manifests
- Using scaffolding tools such as Plaster
- Summary
- Exercises
- Further reading
- Chapter 12: Securing PowerShell
- Why is security so important?
- A PowerShell remoting whistlestop tour
- Enabling PowerShell remoting
- Creating a session
- Joining and leaving a session
- One-to-many sessions
- Securing PowerShell against inadvertent mistakes
- Execution policy
- Other features
- Running PowerShell securely
- Application control
- Language modes
- Security servicing criteria
- Software Bill of Materials
- Windows Antimalware Scan Interface support
- Secure Shell (SSH) remoting
- Just Enough Administration
- PowerShell logging
- Over the shoulder logging
- Deep script block logging
- Module logging
- Writing secure code
- Storing passwords securely
- Signing scripts
- Parameter security
- Summary
- Exercises
- Further reading
- Part 3: Using PowerShell
- Chapter 13: Working with PowerShell 7 and Windows
- Understanding PowerShell 7 and Windows PowerShell
- Exploring compatibility
- Which modules are compatible with PowerShell 7?
- What doesn't work with PowerShell 7
- Managing machines with CIM and WMI
- Introduction to CIM and WMI
- Querying data
- Making changes
- Summary
- Exercises
- Further reading
- Chapter 14: PowerShell 7 for Linux and macOS
- Technical requirements
- Installing PowerShell 7
- Installing PowerShell on Ubuntu 22.04
- Installing PowerShell on CentOS 8 and 9
- Installing PowerShell on CentOS 7
- Installing VS Code
- Running PowerShell on Linux
- Remoting with OpenSSH
- Checking that PowerShell has OpenSSH support
- Installing OpenSSH on Windows
- Installing OpenSSH on Linux
- Running remote sessions
- Authentication
- PowerShell for macOS
- Installing Homebrew on macOS.
- Installing PowerShell on macOS
- Installing VS Code on macOS
- Summary
- Exercises
- Further reading
- Chapter 15: PowerShell 7 and the Raspberry Pi
- Technical requirements
- Introduction to the Raspberry Pi
- Installing PowerShell 7 and VS Code
- Installing PowerShell
- Installing VS Code
- Connecting remotely to the Pi
- Working with a headless Pi
- Connecting to the Pi with PowerShell
- Connecting to the Pi with VS Code
- Running PowerShell on Raspberry Pi OS
- Installing the IoT module
- Exploring the IoT module
- Simple physical computing
- Summary
- Questions
- Further reading
- Chapter 16: Working with PowerShell and .NET
- Exploring .NET
- Software frameworks explained
- Common language infrastructure
- Common language runtime - CoreCLR
- Framework Class Library - CoreFX
- .NET history
- The uses of .NET
- The components of .NET
- Assemblies
- Types
- Enumerations
- Classes
- Namespaces
- Members
- Versioning
- Working with .NET in PowerShell
- PowerShell assemblies
- Dynamic assembly loading
- Creating instances of types
- Using .NET
- An alternative to the Task Scheduler
- Creating GUI objects
- Summary
- Exercises
- Further reading
- Answers to Activities and Exercises
- Index
- Other Books You May Enjoy.