When using PowerShell, not all .NET assemblies are loaded by default in a new PowerShell session. Usually, one would do the following to gain access to an assembly such as System.Web:
Add-Type -AssemblyName System.Web
When working on a PowerShell module, this approach doesn’t work. Even adding that code into one of the .ps1 file components of your module doesn’t seem to help. You still get an ‘Unable to find type’ error as per below:
The solution is to ensure that the following line is populated (and un-commented) in your module manifest:
RequiredAssemblies = @('System.Web')
This is all-the-more important with PowerShell 5.0 and newer when you’re working with classes, and some of the class members are based on external types.