Skip to content
doronshai edited this page Jul 12, 2016 · 4 revisions

Remove Element from XML File using PowerShell

#Set file path
$File = 'C:\Jenkins\workspace\DS_Build_Component\ThisFile.xml'

#Get file contents as XML
[xml]$xml = Get-Content $File

#Remove the content of the 5th property Group
$Remove = $xml.Project.PropertyGroup[4].RemoveAll()

#Save file
$xml.Save($File)

How to handle CLI Arguments

This post

Set Variables as Escaped String

$DeployFolderUNC = "\\$env:COMPUTERNAME\MC_Deployment\$env:JOB_NAME\$ENV:BUILD_ID"
$EscapedDeployFolderUNC = [string]::Format("{0}",$DeployFolderUNC.Replace('\','\\'))
$MCdeployFolderUNC = "MCdeployFolderUNC=$EscapedDeployFolderUNC"