Invoke-DscResource
Runs a method of a specified DSC resource.
Синтаксис
Default (по умолчанию)
Invoke-DscResource
[-Name] <String>
[-Method] <String>
-ModuleName <ModuleSpecification>
-Property <Hashtable>
[<CommonParameters>]
Описание
The Invoke-DscResource
cmdlet runs a method of a specified Windows PowerShell Desired State
Configuration (DSC) resource. Before you run this cmdlet, set the refresh mode of the Local
Configuration Manager (LCM) to Disabled.
This cmdlet invokes a DSC resource directly, without creating a configuration document. Using this cmdlet, configuration management products can manage windows by using DSC resources. This cmdlet also enables debugging of resources when the DSC engine or LCM is running with debugging enabled.
This cmdlet doesn't work with composite resources. Composite resources are parameterized configurations. Using composite resources requires the LCM.
Примеры
Example 1: Invoke the Set method of a resource by specifying its mandatory properties
Invoke-DscResource -Name Log -Method Set -Property @{Message = 'Hello World'} -ModuleName PSDesiredStateConfiguration
This command invokes the Set method of a resource named Log and specifies a Message property for it.
Example 2: Invoke the Test method of a resource for a specified module
Invoke-DscResource -Name WindowsProcess -Method Test -Property @{Path = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'; Arguments = ''} -ModuleName PSDesiredStateConfiguration
This command invokes the Test method of a resource named WindowsProcess, which is in the module named PSDesiredStateConfiguration.
Параметры
-Method
Specifies the method of the resource that this cmdlet invokes. The acceptable values for this parameter are:
Get
Set
Test
Свойства параметра
Тип: | String |
Default value: | None |
Допустимые значения: | Get, Set, Test |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Наборы параметров
(All)
Position: | 1 |
Обязательно: | True |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | True |
Значение из оставшихся аргументов: | False |
-ModuleName
Specifies the name of the module from which this cmdlet invokes the specified resource.
Свойства параметра
Тип: | ModuleSpecification |
Default value: | None |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Наборы параметров
(All)
Position: | Named |
Обязательно: | True |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | True |
Значение из оставшихся аргументов: | False |
-Name
Specifies the name of the DSC resource to start.
Свойства параметра
Тип: | String |
Default value: | None |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Наборы параметров
(All)
Position: | 0 |
Обязательно: | True |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | True |
Значение из оставшихся аргументов: | False |
-Property
Specifies the resource property name and its value in a hash table as key and value, respectively.
Use the Get-DscResource
cmdlet to discover resource properties and their types.
Свойства параметра
Тип: | Hashtable |
Default value: | None |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Наборы параметров
(All)
Position: | Named |
Обязательно: | True |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | True |
Значение из оставшихся аргументов: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.