I’m using TFS 2015 U2 RM to execute DSC configurations on target nodes. This particular configuration would deploy website and has many resources in it. I want to add a Script as my first resource on which other resources would have DependsOn. And in this first Script resource, I want to check if a folder exists and IIS binding exists for the same, prevent other resources from execution. Let me try with an example.
Node ($AllNodes.NodeName) { Script ScriptResource01 { TestScript = { $destinationPath = "E:\Programs\prd\DevCI_20160909.3" if (Test-Path $using:destinationPath) { Write-Verbose -Message "Website already deployed." -Verbose return $true } return $false } SetScript = { Write-Verbose -Message "Paths are valid." -Verbose } GetScript = { @{ Result = "Validate if website already edeployed." } } } Script ScriptResource02 { DependsOn = @("[Script]ScriptResource01") TestScript = { return $false } SetScript = { Write-Verbose -Message "Deploying website in this block" -Verbose } GetScript = { @{ Result = "Copies the website content to the right folder." } } } }
In this example, I want to prevent execution of ScriptResource02 if ScriptResource01’s SetScript didn’t run.
If I use Write-Error it stops the execution however TFS RM console also fails-out which is unwanted for us.
Thanks for your help.