YUNOVA · PowerShell
Module 11: Advanced PowerShell
Advanced functions with CmdletBinding and pipeline input
Key points
- [CmdletBinding()] gives a function common parameters like -Verbose.
- ValueFromPipeline lets a parameter take objects from the pipeline.
- Pipeline input is handled one object at a time in the process block.
PowerShell classes
Key points
- Classes are defined with the class keyword and hold properties and methods.
- Constructors set up a new object when it is created.
- Classes can inherit from another class to reuse its members.
Pester testing in PowerShell
Key points
- Pester is the standard testing framework for PowerShell.
- Tests are written with Describe, It and Should blocks.
- Mocks replace real commands so tests run safely.
PowerShell DSC desired state configuration
Key points
- DSC describes how a system should be configured instead of the steps.
- Resources handle items such as files, services and features.
- DSC can check for drift and bring a machine back to the desired state.
SecretManagement module for credentials
Key points
- SecretManagement gives one set of commands for different secret vaults.
- Get-Secret and Set-Secret read and store secrets.
- Scripts fetch credentials at run time instead of storing them in code.