PowerShell Overview
PowerShell was first introduced in 2008 as a scripting language for Windows Server. Over the years it has evolved to an open-source, cross platform solution that can be used on Windows, Linux and macOS.
- PowerShell Overview
- Brushing up on objects
- PowerShell Versions
- Windows PowerShell versus PowerShell
- Concepts and Terminology
- Getting Commands
- Getting Help
- Providers and Drives
- LAB: PowerShell Overview
PowerShell Shells
The Windows PowerShell Integrated Scripting Environment (ISE) is a script editor for Windows PowerShell that allows you to run commands and write, test, and debug scripts in a single graphical interface.
In addition to the PowerShell ISE, PowerShell is also well-supported in Visual Studio Code with rich intellisense and advanced debugging features.
- PowerShell Console
- Integrated Scripting Environment (ISE)
- Visual Studio Code
- LAB:PowerShell Shells
Core Concepts
Using the pipe operator in PowerShell you can easily perform complex operations in a single line of code. Format cmdlets can be used to change the default output of a command and the Out comdlets allow you to send data to a text file or grid.
- Viewing Object Structure
- Object Pipeline
- Using Format Cmdlets to Change Output
- Export Data with Out Cmdlets
- Using Variables to Store Objects
- LAB: Core Concepts
Object Pipeline Processing
PowerShell contains a bunch of commands that allow you to manipulate your objects using the pipeline. These cmdlets will help you to filter, sort, group, … any object.
- Where-Object
- Foreach-Object
- Select-Object
- Sort-Object
- Measure-Object
- Compare-Object
- Group-Object
- Tee-Object
- LAB: Object Pipeline Processing
Working with Objects
PowerShell works mostly with .NET objects but also provides full access to COM and WMI.
- Files and Folders
- Registry Keys and Values
- COM Objects
- WMI Objects – CIMCmdlets
- .NET Objects
- Static Classes
- LAB: Working with Objects
Extending PowerShell Functionality
A module is a set of related PowerShell functionalities, grouped together as a convenient unit. To manage different services the correct modules must be downloaded and installed on your machine.
- Modules
- PowerShellGet and the PowerShell Gallery
- PowerShell Profiles
- Operators and Expressions
- LAB: Extending PowerShell Functionality
PowerShell Security
The execution policy is part of the security strategy of PowerShell.
It determines whether you can load configuration files and run scripts, and it determines which scripts, if any, must be digitally signed before they will run.
- PowerShell Execution Policy
- Script Signing
- Security Sensitive Information in Scripts
- LAB: PowerShell Security
PowerShell Remoting
PowerShell Remoting lets you run PowerShell commands or access full PowerShell sessions on remote systems.
- PowerShell Remoting Overview
- WS-Management (WSMAN)
- Remote CIM Sessions
- Import/Export Remoting Sessions
- WinRM Security
- WinRM Double Hop Problem
- Using Variables in Remoting Sessions
- LAB: PowerShell Remoting
PowerShell Jobs
Jobs are long-running tasks that are executed in the background. You don’t have to wait for the job to finish and can perform other tasks while the job is running.
Once completed, the job output can be retrieved. Jobs can be executed on a remote system or they can be scheduled.
- Background Jobs
- Remoting Jobs
- Scheduled Jobs
- LAB:PowerShell Jobs
Managing Your Environment
The goal of PowerShell is to ease your work as an administrator. In this module we will talk about basic management tasks that you need
to perform and how you can accomplish these through PowerShell.
Configuring network settings, implementing security on files and folders, managing Active Directory.
- Networking
- File Shares
- Data Import
- Security
- Server Management
- Active Directory
- Certificates
- LAB: Managing Your Environment
Error Handling
With the out of the box possibilities, you can easily debug your scripts before running them in production.
You can set breakpoints and use standard debugging options like step over, step into, step out.
To modify the default PowerShell error handling behavior, you can write a trap or try-catch statement and run special code when errors are encountered.
- Debugging options
- Error Handling
- Trap Statement
- Try – Catch Statement
- LAB: Error Handling
PowerShell Script Statements
Script statements allow you to write loops or conditional code.
- Foreach
- For
- While – Do While – Do Until
- If – Switch
- Break – Continue
- LAB: PowerShell Scripting
Advanced Scripting
Functions allow you to reuse your PowerShell code across various scripts. Custom objects can be used to store any form of data.
- Working with Custom Objects
- PowerShell Functions
- PowerShell Scopes
- Script Basics: Parameters, Nested Scripts
- $PSBoundParameters
- Splatting
- LAB: Advanced Scripting
Create Custom PowerShell Cmdlets and Modules
Turn your real time management and automation scripts into useful reusable tools and cmdlets.
Use PowerShell to create your own modules.
- Creating a PowerShell Module
- Creating your own Cmdlets
- Command Documentation
- Advanced Parameter Configuration
- Pipeline Support
- ShouldProcess Support
- Creating a Private PowerShell Module Repository
- LAB: Create a Module and Custom PowerShell Cmdlets
DevOps: Desired State Configuration
DSC allows for declaratively specifying how a software environment should be configured. Upon running a configuration, DSC will ensure that the system gets the state described in the configuration.
DSC configurations are idempotent. The Local Configuration Manager (LCM) periodically polls the system using the control flow described by resources to make sure that the state of a configuration is maintained.
- Desired State Configuration Overview
- DSC Components: Configuration – Node – Resource
- Apply DSC Configurations
- Push versus Pull Mode
- Azure Automation DSC
- LAB: Desired State Configuration