For reasons of script portability, I need to dynamically load snap-ins in a PowerShell script. This is easily accomplished in PowerShell v2 with the Load-Module
function. I need to run this particular script on a machine where I, for various reasons, do not want to install PowerShell v2, but have v1.
Is there a Load-Module
equivalent in PowerShell v1?
Do you mean
Import-Module
? If so, then it depends on how the module is defined. If it is a snapin DLL, then the snapin would need to be installed on the V1 machine and then you would useAdd-PSSnapin
. If it is in.psm1
file, then you would need to rename the file to.ps1
and then you could try to dot source it e.g.. .\mymodule.ps1
. However if it uses any v2 feature like Export-ModuleMember, you will need to comment those out. And v1 wouldn't know what to do with a.psd1
file.