On the current version of WMF5, I try and invoke a DSC resource using Invoke-DSCResource like so:
$destinationPath="$env:SystemDrive\DirectAccess.txt"
$fileContents="This file is create by Invoke-DscResource"
$result = Invoke-DscResource -Name File -Method Test -Property @{
DestinationPath=$destinationPath
Contents=$fileContents } -Verbose
$result | fl *
However, I'm asked for a module name for the "File" resource.
Doing Get-DscResource File lists the dsc resource, but the "module" property is empty. How can I figure out which module to pass Invoke-DscResource? Where (in what module) does the "File" resource really live?
PSDesiredStateConfiguration was the correct module (can be seen in compiled mof when using the file resource). Apparently "File" is a weird DSC resource.
The File resource in DSC is implemented as a WMI provider (the only resource that way) while the rest of the resources are implemented as PowerShell resources. Invoke-DscResource only works with PowerShell resources hence you will not be able to invoke it on File.