Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 2
    Your answer is great, short and effective :) you just miss $schemaReader.Dispose() which causes schema file lock
    – Adassko
    Commented Jan 9, 2018 at 14:08
  • 1
    Thanks; I have updated my answer with an updated version that is written as a function that can be included in a module and supports pipeline.
    – wangzq
    Commented Jan 9, 2018 at 22:41
  • 1
    For others viewing this, it does work on PSv4 (running on a Windows Server 2012 R2 box). And by extension, this will work in PSv5 and PSv5.1, too. Not sure about PS Core, I haven't tried. Commented Nov 11, 2020 at 20:48
  • Why does validate take a scriptblock as input? The documentation says it needs to be of type ValidationEventHandler.
    – Blaisem
    Commented Dec 24, 2022 at 20:33