PowerShell Logo Small

Invoke-DscResource



This is the built-in help made by Microsoft for the command 'Invoke-DscResource', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Runs a method of a specified DSC resource.

SYNTAX


Invoke-DscResource [-Name] <String> [-Method] {Get | Set | Test} [-ModuleName [<ModuleSpecification>]] -Property <Hashtable> [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Invoke-DscResource cmdlet executes a method of a specified 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.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkId=627544
Windows PowerShell Desired State Configuration Overview
Get-DscConfiguration
Get-DscConfigurationStatus
Restore-DscConfiguration
Set-DscLocalConfigurationManager
Start-DscConfiguration
Test-DscConfiguration

REMARKS

<

Examples


Example 1: Invoke the Set method of a resource by specifying its mandatory properties

PS C:\>Invoke-DscResource -Name Log -Method Set -Property @{Message = 'Hello World'}



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

PS C:\>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.