Skip to content

Commit 373ca78

Browse files
authored
Fixes #4382 - Add ModuleVersion parameter (#4845)
* Fixes #4382 - Add ModuleVersion parameter * edits
1 parent 1e2011c commit 373ca78

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

dsc/configurations/import-dscresource.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ title: Using Import-DSCResource
1111
The syntax for `Import-DSCResource` is shown below. When specifying modules by name, it is a requirement to list each on a new line.
1212

1313
```syntax
14-
Import-DscResource [-Name <ResourceName(s)>] [-ModuleName <ModuleName>]
14+
Import-DscResource [-Name <ResourceName(s)>] [-ModuleName <ModuleName>] [-ModuleVersion <ModuleVersion>]
1515
```
1616

1717
|Parameter |Description |
1818
|---------|---------|
1919
|`-Name`|The DSC resource name(s) that you must import. If the module name is specified, the command searches for these DSC resources within this module; otherwise the command searches the DSC resources in all DSC resource paths. Wildcards are supported.|
2020
|`-ModuleName`|The module name, or module specification. If you specify resources to import from a module, the command will try to import only those resources. If you specify the module only, the command imports all the DSC resources in the module.|
21+
|`-ModuleVersion`|Beginning in PowerShell 5.0, you can specify which version of a module a configuration should use. For more information, see [Import a specific version of an installed resource](sxsresource.md).|
2122

2223
```powershell
23-
Import-DscResource -ModuleName xActiveDirectory;
24+
Import-DscResource -ModuleName xActiveDirectory
2425
```
2526

2627
## Example: Use Import-DSCResource within a configuration
@@ -30,7 +31,7 @@ Configuration MSDSCConfiguration
3031
{
3132
# Search for and imports Service, File, and Registry from the module PSDesiredStateConfiguration.
3233
Import-DSCResource -ModuleName PSDesiredStateConfiguration -Name Service, File, Registry
33-
34+
3435
# Search for and import Resource1 from the module that defines it.
3536
# If only –Name parameter is used then resources can belong to different PowerShell modules as well.
3637
# TimeZone resource is from the ComputerManagementDSC module which is not installed by default.
@@ -42,7 +43,8 @@ Configuration MSDSCConfiguration
4243
# Search for and import all DSC resources inside the module PSDesiredStateConfiguration.
4344
# When specifying the modulename parameter, it is a requirement to list each on a new line.
4445
Import-DSCResource -ModuleName PSDesiredStateConfiguration
45-
Import-DSCResource -ModuleName ComputerManagementDsc
46+
# In PowerShell 5.0 and later, you can specify a ModuleVersion parameter
47+
Import-DSCResource -ModuleName ComputerManagementDsc -ModuleVersion 6.0.0.0
4648
...
4749
```
4850

@@ -142,6 +144,10 @@ Copy the contents of your desired module version to the top level of the module
142144
143145
When authoring and compiling Configurations, your resources can be stored in any directory specified by your [PSModulePath](/powershell/developer/module/modifying-the-psmodulepath-installation-path). In PowerShell 4.0, the LCM requires all DSC resource modules to be stored under "Program Files\WindowsPowerShell\Modules" or `$pshome\Modules`. Beginning in PowerShell 5.0, this requirement was removed, and resource modules can be stored in any directory specified by `PSModulePath`.
144146
147+
### ModuleVersion added
148+
149+
Beginning in PowerShell 5.0, the `-ModuleVersion` parameter allows you to specify which version of a module to use within your configuration.
150+
145151
## See also
146152
147153
- [Resources](../resources/resources.md)

0 commit comments

Comments
 (0)