#region Forms $lcmSourceDir = "Z:\Downloads\KG04\HP-SanPlan\resource\Plan Type\SanPlan1\Data Forms\" $dimName = "CustomerSegment" # List all files $files = Get-ChildItem $lcmSourceDir -Recurse | where {$_.Attributes -notmatch 'Directory'} | # Remove CustomerSegment Foreach-Object { $fileCount = 0 [xml]$xml = Get-Content $_.FullName $node = $xml.SelectNodes("//dimension") | Where-Object {$_.name -eq $dimName} | ForEach-Object { #Increase the counter $fileCount++ # Remove each node from its parent [void]$_.ParentNode.RemoveChild($_) } if($fileCount -ge 1) { $xml.save($_.FullName) Write-Host "$_.FullName updated." } } #endregion #region CompositForms $lcmSourceDir = "Z:\Downloads\KG04\HP-SanPlan\resource\Global Artifacts\Composite Forms" $dimName = "CustomerSegment" # List all files $files = Get-ChildItem $lcmSourceDir -Recurse | where {$_.Attributes -notmatch 'Directory'} | # Remove CustomerSegment Foreach-Object { $fileCount = 0 [xml]$xml = Get-Content $_.FullName $node = $xml.SelectNodes("//sharedDimension") | Where-Object {$_.dimension -eq $dimName} | ForEach-Object { #Increase the counter $fileCount++ # Remove each node from its parent [void]$_.ParentNode.RemoveChild($_) } if($fileCount -ge 1) { $xml.save($_.FullName) Write-Host "$_.FullName updated." } } #endregion