Change Node Name through Code or Command

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Daniel Krebs Daniel Krebs 2 years, 1 month ago.

  • Author
    Posts
  • #19660
    Profile photo of mayuri naware
    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
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

    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.