Dependency in ForEach loop

Welcome Forums DSC (Desired State Configuration) Dependency in ForEach loop

Viewing 0 reply threads
  • Author
    Posts
    • #195542
      Participant
      Topics: 1
      Replies: 2
      Points: 23
      Rank: Member

      Hi,

      I have a case where i need to create some mount points that point to pre-created folders. The folder structure is created by a File resource in a ForEach loop. Then the same path of previously created folders is used in a DiskAccessPath resource ForEach loop that creates the mount points.

      Configuration Data:

      SQL14Data = @{
         DriveLetter = 'G'
         DiskLabel = 'SQL'
         BlockSize = 64KB
         Id = 2
         DependsOn = '[File]TLog','[File]TempDb','[File]Data'
      MountPoints = @(
         @{
              Name = 'TLog'
              Label = 'TRANSLOG'
              Id = 3
              Path = 'G:\MSSQL14.MSSQLSERVER\MSSQL\TRANSLOG'
          },
         @{
             Name = 'TempDb'
             Label = 'TEMPDB'
             Id = 4
             Path = 'G:\MSSQL14.MSSQLSERVER\MSSQL\TEMPDB'
          },
          @{
             Name = 'Data'
             Label = 'DATA'
             Id = 5
             Path = 'G:\MSSQL14.MSSQLSERVER\MSSQL\DATA'
          }
      )
      }

      This is the code:

      $ConfigurationData.SQL14Data.MountPoints.ForEach( {
                  File $_.Name
                  {
                      DestinationPath = $_.Path
                      Type            = 'Directory'
                      Ensure          = 'Present'
                      DependsOn       = '[WaitForDisk]SQLDisk'
                  }
              } )
              $ConfigurationData.SQL14Data.MountPoints.ForEach( {
                  DiskAccessPath $_.Name
                  {
                      DiskId             = $_.Id
                      AccessPath         = $_.Path
                      AllocationUnitSize = $ConfigurationData.SQL14Data.BlockSize
                      FSLabel            = $_.Label
                      FSFormat           = 'NTFS'
                      DependsOn          = $ConfigurationData.SQL14Data.DependsOn
                  }
              } )

      It looks like the DependsOn in the DiskAccessPath loop doesn't work. Or at least not the way i was expecting it to work. It constantly tries to create the mount points before the folder structure is created.

      Please let me know what i'm doing wrong here.

      Thank you in advance.

Viewing 0 reply threads
  • You must be logged in to reply to this topic.