Thursday, 9 May 2019

Validating Unattend.xml or autounattend.xml against the schema

I'm trying to sort out CI builds using TFS/VSTS that use packer and other tools.

Currently I use packer validate to prove that its working ok, but there appeared to be no way of validating the answer files for windows other than loading them into the AIK.

I found a blog post here http://schneegans.de/computer/unattend-schema/ which suggested how to get at the schema, so I set about knocking some powershell functions together to extract the schema programatically (I'm not posting the schema as I dont want to start having to read too many licence agreements) and then use this to validate the XML against what is in the schema.

I appreciate there is a fair bit of refactoring that could be done and no pester tests - but I've cobbled / pasted these together in this format for the purposes of the internet and removed logic that is only appropriate for my environment.

Not saying they will be perfect or usuable in every locale.. Works on my machine though.

script is located here https://gist.github.com/davidwallis3101/48454cb6c17c988de43b5ea17089ea6f



No comments:

Post a Comment