Thursday 12 February 2015

PowerShell DSC in legacy pipelines, or with no pipeline at all

It is true that PowerShell DSC is the newest kid on the block, but it is also true that we can integrate it in legacy pipelines, or where we have no clear pipeline whatsoever.

How? Pretty easy – even if there is DSC in the name, we are still talking about PowerShell, hence who can stop us from invoking a legacy script or even a command?

For example, think about where you have a script which stops IIS, copies the new content and then the scripts restarts IIS, using iisreset and xcopy. Not best practice at all, but it is broadly used. You can replace it with this:

image

The Invoke-Command cmdlet is a standard PowerShell one, it has nothing to do with DSC. But embedded into a DSC script it can make a functional step into the DSC script itself.

Even better, do you have a preparation script which prepares the environment? You can use Invoke-Command with the –FilePath switch, pointing at your script, as part of the DSC script.

No comments:

Post a Comment