4

The articles all discuss staging, packaging and a bunch of infrastructure aspects.

Is it possible to just run the scripts, either locally, or (preferable!) against a remote server?

E.g. infrastructure-free, like I can run ssh commands now?

Jonesome Reinstate Monica
  • 5,445
  • 10
  • 56
  • 82

1 Answers1

4

Yes, what you're looking for is "Push" mode. Instead of setting up a pull server and using a GUID to name the files, you just run Start-DscConfiguration against the local machine or a remote machine.

You still need Windows Management Framework 4 installed and the target node must allow incoming WinRM connections, even if the target is the local node.

This is not exactly comparable to using SSH though, because once you apply the configuration it will be reapplied automatically. When you install the Windows PowerShell Desired State Configuration Service Feature, it automatically sets up the LCM in Pull mode. To see that, run Get-DscLocalConfigurationManager. You'll also see the settings for how often the configuration is checked for changes (30 minutes by default) and how often the current configuration is re-applied (15 minutes by default). Once you've actually pushed a config, a scheduled task called Consistency will show up under Task Scheduler Library\Microsoft\Windows\Desired State Configuration which actually does the work here.

I also want to clarify that you don't directly apply the configuration scripts that you write in Powershell. Whether you push or pull the configs, you still have to execute the script first to "compile" it into an MOF file, and that's the file that gets applied.

A better analogue to SSH is Powershell remoting, which allows you to run code against a remote machine or use an interactive prompt in a remote machine. That requires Powershell remoting to be enabled on the target machine. For that you would use Enter-PSSession for an interactive prompt, or use Invoke-Command to run a script block on the remote machine(s).

briantist
  • 2,545
  • 1
  • 19
  • 34
  • Thanks! "once you apply the configuration it will be reapplied automatically." means that if the target machine is modded (one of the aspects configed by the DSC is changed), the DSC is auto-magically re applied, correct? – Jonesome Reinstate Monica Dec 26 '14 at 16:39
  • Yes, but on a schedule. It won't immediately know and re-apply. See my edit where I expanded on this concept a bit. – briantist Dec 26 '14 at 16:55