PowerShellOnTargetMachines TFS2015 Initialization Script not working

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of Michael Greene Michael Greene 1 week, 6 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #54178
    Profile photo of Jimmy N
    Jimmy N
    Participant

    Hello,

    I have a problem with getting PowerShellOnTargetMachines working during release while I provide Initialization Script.

    The bottom line is I need to execute single ps1 DSC script on multiple servers while at the same time apply different parameters to each of those servers so thought I will just keep those parameters in psd1 file.

    Here is my script LiquidDeploy.ps1:

    Configuration LiquidDeploy
    {
    Node $AllNodes.ForEach("NodeName")
    {
    switch ($Node.Role)
    {
    "GW"
    {
    if ($NodeName -eq $env:COMPUTERNAME)
    {
    Write-Verbose $Node.Message
    }
    }
    "APP"
    {
    if ($NodeName -eq $env:COMPUTERNAME)
    {
    Write-Verbose $Node.Message
    }
    }
    default { throw "No role assigned to $NodeName" }
    }
    }
    }

    and here is the configuration file New.psd1:

    @{
    AllNodes = @(
    @{
    NodeName = "localhost"
    Message = "my message"
    Role = "APP"
    },
    @{
    NodeName = "test2"
    Message = "my message"
    Role = "GW"
    }
    )
    }

    In task I provide only:
    Machine name (which supposed to be the same as the one in config file so I can match it)
    PowerShell Script
    Initialization Script

    and that's it when I run it finish successfully but nothing happen !
    It only works where I put inside ethe script file rows to kick off DSC script with the path to data file but it beat the purpose of providing file as a parameter in the task...

    LiquidDeploy -ConfigurationData C:\Temp\LiquidDrop\Scripts\New.psd1 -OutputPath C:\Temp\OutputPath -Verbose
    Start-DscConfiguration -Path C:\Temp\OutputPath -wait –Verbose

    #54183
    Profile photo of Arie H
    Arie H
    Participant

    I think you need to store the data you have inside your psd1 file as a variable outside of PS, in the Release or Deploy templates. I remember I used to do it in the earlier version of ReleaseManagement that's now bundled inside TFS 2015 update 2.

    haven't tried it in TFS 2015 yet as I'm still working on upgrades from 2013 and from RM to the new Deploy\Release

    • This reply was modified 1 week, 6 days ago by Profile photo of Arie H Arie H.
    #54187
    Profile photo of Michael Greene
    Michael Greene
    Participant

    Take a look at the approach in the following repo. It is not representing multiple machines but I believe it demonstrates an approach that could meet that requirement.

    Generating the config data:
    https://github.com/PowerShell/Demo_CI/blob/master/InfraDNS/DevEnv.ps1

    Building the MOF(s) including config data:
    https://github.com/PowerShell/Demo_CI/blob/master/InfraDNS/Deploy.ps1#L55

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.