quickstart-microsoft-sql icon indicating copy to clipboard operation
quickstart-microsoft-sql copied to clipboard

Make directory creation idempotent

Open kjhosein opened this issue 6 years ago • 3 comments

Description of changes: Add -Force param to new dir creation to allow future runs to be error-free.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

kjhosein avatar Jul 10 '19 19:07 kjhosein

Just to make sure I am clear on this one, the -Force is where the Idempotency comes in? Should a If statement or something added to Check? Should this be put in a Custom Script Block in DSC? Look forward to hearing your feedback and thoughts.

virtlima avatar Jul 19 '19 14:07 virtlima

Yep, the -Force ignores the error if the directory already exists and doesn't mess with anything previously created. e.g. if you create a dir and even add items to it, re-running New-Item ... -Force leaves things intact. Perhaps not the best named flag! ;-)

IMHO, I don't think you need an if statement since the New-Item cmdlet already has this built-in mechanism. I also don't think you need it in the custom script block either for the same reason. HTH!

kjhosein avatar Jul 23 '19 15:07 kjhosein

Cool Thanks I am testing this and the other PR, it failed so I need to determine cause. I will throw up errors in bit.

virtlima avatar Jul 23 '19 15:07 virtlima