Dependency in ForEach loop

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.