LTI/ZTI PowerShell: Using Modules in deployment scripts

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
 $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.


Technet Wiki – Popular PowerShell Modules (en-US)
Import-Module cmdlet

About Andrew Barnes

A Scripting and Deployment Specialist.
This entry was posted in MDT 2010, MDT 2012, PowerShell, Scripting and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s