Q: I'm using PowerShell Desired State Configuration and want to create a configuration that will work for any computer; how can I do this?
A: You typicallly specify configuration for specific nodes in a PowerShell configuration; for example:
Node websrv1 { ... }
There are several ways to make a configuration work for any machine. One method is to just use localhost, which would then work for any machine; for example:
Node localhost { ... }
You can also create a hashtable of entries, with each entry a specific node that can then be used and passed in a configuration. This method is discussed in the Windows PowerShell Blog post "Separating 'What' from 'Where' in PowerShell DSC." One of these entries can be * for all hosts.
Another option is to pass the machine name as a parameter to the configuration and then specify a unique name each time you want to compile a new configuration; for example:
Configuration SavillTechWebsite { param ( # Target nodes to apply the configuration [string[]]$NodeName = 'localhost' ) # Import the module that defines custom resources Import-DscResource -Module xWebAdministration Node $NodeName { ... } } SavillTechWebsite -Machinename websrv1