Change Node Name through Code or Command

Is there any way to have the node name in configuration data file to be changed through program or and command. Actually I am creating DSC scripts and after that I am provisioning a new VM so till the Vm is created I dont know the node name and my DSC scripts are copied there and then they needs to be run, so I want to change the node name automatically in Configuration data after VM is created.

Thanks in advance :slight_smile:

If your configuration script takes the node name as parameter you can specify any name necessary to generate the MOF document.

Configuration Example
{
  Param
  (
    [Parameter(Mandatory)]
    [String] $NodeName
  )

  Node $NodeName
  {
    # ...
  }
}

Example -NodeName HelloWorld
# Will generate HelloWorld.mof

Example -NodeName 4d383c33-aefe-422b-8329-b2b0544fd958
# Will generate 4d383c33-aefe-422b-8329-b2b0544fd958.mof