I wanted to try out the DSC in Powershell 4.0 on my Windows 8.1 Pro machine, but I got stuck on the ‘getting started’ part. I just couldn’t figure out how to generate the actual configuration files (.mof-files).
I google around quite a bit before I finally got it; the configuration file that you create is off course just like a normal script file in the sense that it doesn’t actually do anything. All it does is to define a function that you need to call!
So in order to actually generate the .mof-files, I ‘dot-sourced’ the script into the current session and called the function from the ps1-file.
Here’s an example configuration file called ‘demoConfig.ps1’:
SourcePath = "c:\temp\test.txt"
DestinationPath = "c:\temp\testdir"
Ensure = "Present"
Type = "File"
And to generate the .mof files:
PS C:\temp> . .\demoConfig.ps1
PS C:\temp> Demo