Last active
August 29, 2015 14:23
-
-
Save djfr/cb9baaa000dc8f6ce4b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param | |
( | |
[parameter(Mandatory=$true)] | |
[string] | |
$Xml, | |
[parameter(Mandatory=$true)] | |
[string] | |
$Xdt | |
) | |
if (!(Test-Path -path $Xml -PathType Leaf)) | |
{ | |
throw "XML File not found. $Xml" | |
} | |
if (!(Test-Path -path $Xdt -PathType Leaf)) | |
{ | |
throw "XDT File not found. $Xdt" | |
} | |
Add-Type -LiteralPath "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\spzpqgng.yjx\Microsoft.Web.XmlTransform.dll" | |
$xmldoc = New-Object Microsoft.Web.XmlTransform.XmlTransformableDocument | |
$xmldoc.PreserveWhitespace = $true | |
$xmldoc.Load($Xml) | |
$transf = New-Object Microsoft.Web.XmlTransform.XmlTransformation($xdt) | |
if ($transf.Apply($xmldoc) -eq $false) | |
{ | |
throw "Transformation failed." | |
} | |
$xmldoc.Save("$PSScriptRoot\out.xml") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment