## pwsh -NoProfile -ExecutionPolicy Bypass -File xmlformatter.ps1 XMLファイル名 param( [Parameter(Mandatory = $true)] [string] $InputPath ) Add-Type -AssemblyName System.Xml.Linq if (Test-Path $InputPath) { $dir = (Get-Location).Path $base = [System.IO.Path]::GetFileNameWithoutExtension($InputPath) $OutputPath = [System.IO.Path]::Combine($dir, ($base + ".new.xml")) } else { Write-Host "ファイルなし" exit } ## 整形用にインデントを指示 $settings = [System.Xml.Linq.SaveOptions]::None ## XML読み込み $xmldoc = [System.Xml.Linq.XDocument]::Load($InputPath) ## XML整形結果書き出し $xmldoc.Save($OutputPath, $settings)