?
Hi Paul,
Your best bet would probably be to use Role Dependencies - the parent role would ensure that the module is installed:
# Parent Role
PSEnsure
(
Key: InstallDSC,
Value: 0,
Collect: "if(Get-Module -Name cNtfsAccessControl -List -ErrorAction SilentlyContinue) { exit 0 } else { exit -1 }",
Configure: install-module -Name cNtfsAccessControl -Force,
UseExitCode: true
);
Then, in the dependent role, you can safely use the module:
# Dependent Role
PSDsc cNtfsAccessControl::cNtfsPermissionsInheritance
(
Otter_ConfigurationKey: ApplyPermissions_Key,
Path: c:\temp,
PreserveInherited: true,
Enabled: true
);
Note that this usage of Role Dependencies will require Otter 2.0.8 or later. In any case, if you don't want to or can't use Role Dependencies, you can simply put the PSEnsure operation inside an alwaysExecute block.
Does this help?