Change Node Name through Code or Command

This topic contains 1 reply, has 2 voices, and was last updated by  Daniel Krebs 3 years, 2 months ago.

  • Author
    Posts
  • #19660

    mayuri naware
    Participant

    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 🙂

  • #19661

    Daniel Krebs
    Moderator

    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
    

You must be logged in to reply to this topic.