The main idea of this post is to gather a lot of Open Source tools together to check the Quality of PowerShell scripts and provide Code Coverage based on PowerShell Unit Tests.
In my job, in order to manage a Microsoft 365 environment, it is necessary to use PowerShell to:
- Access all features, even those which are not visible from the Admin UI
- Implement Continuous Deployment
- "Package" a set of configurations
When developers develop, it exists some tools to ensure the quality of their code and perform Code Coverage. So why don't we do this with PowerShell scripts? Do some equivalent tools exist to check the PowerShell scripts and perform a Code Coverage? The answer is YES! 🙌🏻 Ok, so let's go.
In addition, to gather all of these tools together, I list the prerequisites and the information about their usage with personal feedback on their capabilities and efficiency.
PowerShell Scripts Overview
To be able to create reports of Code Quality and efficient Code Coverage for your scripts, you have to follow some Best Practices that are almost all illustrated in the Microsoft documentation:
This is certainly the only tool that allows performing real code coverages:
- A lot of samples and documentations
- Exists for a couple of years
- Relatively easy to use
- Enough options to use it from the developer computer and from pipelines