[CmdletBinding()] Param( [Parameter(Mandatory = $True, Position = 1)] [string]$monacoWxsFile ) $fileWxs = Get-Content $monacoWxsFile; $fileWxs = $fileWxs -replace " KeyPath=`"yes`" ", " " $newFileContent = "" $componentId = "error" $directories = @() $fileWxs | ForEach-Object { $line = $_; if ($line -match "") { $line += @" `r`n `r`n "@ } if ($line -match "") { $directories += $matches[1] } if ($line -match "") { $line = @" "@ } $newFileContent += $line + "`r`n"; } $removeFolderEntries = @" `r`n `r`n "@ $directories | ForEach-Object { $removeFolderEntries += @" "@ } $removeFolderEntries += @" "@ $newFileContent = $newFileContent -replace "\s+()", "$removeFolderEntries`r`n " Set-Content -Path $monacoWxsFile -Value $newFileContent