
A great feature of PowerShell is the use of Modules. You use modules to store reusable code such as functions as an alternate to storing hefty code at the start of your scripts.
MDT supports the use of modules in your deployments scripts. To use a module simply add the module folder to your deployment share under \Tools\Modules. Here I’ve added the PSPKI module for use later in a Hydration Kit I’m working on.
Any modules added there can be called directly in your Deployment scripts by using the Import-Module cmdlet. You do not need to specify a path to the module if stored in this location. It might be an idea to put your functions into a module rather than have loads of code at the start of your scripts.
Modules are useful for calling complex code, here I’ve use the excellent PSPKI module to configure my Certificate Revocation List for my Public Key Infrastructure.
Begin {
Import-Module PSPKI
}
Process{
$UserDNSDomain = ($Env:USERDNSDOMAIN).ToLower()
Get-CA | Get-CDP | Add-CDP -URI "6:http://crl.$UserDNSDomain/crld/<CAName><CRLNameSuffix><DeltaCRLAllowed>.crl" | Set-CrlDistributionPoint
Get-CA | Get-CDP | Add-CDP -URI "65:\\CON-APP1\crldist$\<CAName><CRLNameSuffix><DeltaCRLAllowed>.crl" | Set-CrlDistributionPoint -RestartCA
}
If you’re creating deployment media then the modules will be automatically added to your media from this location.
References:
about_Modules
Technet Wiki – Popular PowerShell Modules (en-US)
Import-Module cmdlet



















