The Invoke-DscRessource allows this.
Ensure-DSC should be improved, if possible. It's been a long time since Otter was updated
Invoke-DscResource -Method Test -Name WindowsFeature -Property @{Name='RSAT-AD-PowerShell'; IncludeAllSubFeature=$true; ensure='Present'} -ModuleName @{ModuleName=’PSDscResources’; ModuleVersion=2.2.0.0’} -Verbose
As enhancement, it would be nice to have a function Ensure-Module in order to manage properly PS Module.
I have done a small set of functions based on PackageManagement but it does not work properly for the Module installation as it does remove the old version.
##AH:UseTextMode
##AH:Description Définition d'un dépôt
module PackageManagementSource<$Nom, $Ensure = present, $SourceLocation, $ProviderName = PowerShellGet, $InstallationPolicy = Untrusted>
{
Ensure-DscResource
(
ConfigurationKey: Name,
Name: PackageManagementSource,
Module: PackageManagement,
Properties: %(Name:$Nom,ProviderName:$ProviderName,SourceLocation:$SourceLocation,InstallationPolicy:$InstallationPolicy,Ensure:$Ensure)
)
}
##AH:UseTextMode
##AH:Description Installation de modules PS à partir d'un dépôt
module PackageManagement<$Module, $Version, $Source = internal-psm, $Ensure = Present>
{
log-information Module: $Module - $Version - $Ensure;
Ensure-DscResource
(
ConfigurationKey: Name,
Name: PackageManagement,
Module: PackageManagement,
Properties: %(Name:$Module,RequiredVersion:$Version,Source:$Source,Ensure:$Ensure)
);
}
note:
There are some prerequisites to have PackageManagement 1.4.7.