Application Delivery Management
Application Modernization & Connectivity
CyberRes
IT Operations Management
$ErrorActionPreference = "stop"
Set-Location $PSScriptRoot
$counter = 0
# Iterate through all files that are .xml
$files = Get-ChildItem '.' -Recurse *.xml | ? {
Test-Path $_.FullName -PathType Leaf
$xml = New-Object -TypeName XML
# Load the file
try {
$xml.Load($_.FullName)
}
catch{}
$selector = $null
try {
# Collect all nodes
$selector = Select-XML -Xml $xml -XPath '//*[@disabled="true"]'
if ($selector -ne $null)
{
# If they exist, iterate through them and remove
Foreach($item in $selector)
{
Write-Host $_.FullName
# Remove the node
$null = $item.Node.ParentNode.RemoveChild($item.node)
$counter
}
# Save the file
# Probably possible to combine the three lines below, right now we're saving twice.
$xml.Save($_.FullName)
$content = Get-Content $_.FullName
$content | Out-File $_.FullName -Encoding OEM
}
}
catch {$_.Exception.message}
}
Write-Host $counter "occurences of disabled='true' found"
powershell .\<scriptname>.ps1.
powershell Set-ExecutionPolicy <execution policy value>.
C:\Windows\system32> powershell $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 17134 590