Код:

$sOldFile = 'C:\Мои проекты\0241\old.txt'
$sNewFile = 'C:\Мои проекты\0241\new.txt'
$sResultFile = 'C:\Мои проекты\0241\result.txt'
Get-Content -Path $sNewFile | ForEach-Object -Begin {
$hNewTable = @{}
} -Process {
$hNewTable.Add([IO.Path]::GetFileNameWithoutExtension($_), $_)
}
Get-Content -Path $sOldFile | ForEach-Object -Process {
$sOldName = ([IO.Path]::GetFileNameWithoutExtension($_)).Replace('_', '')
if($hNewTable.ContainsKey($sOldName)) {
"$($_) | $($hNewTable[$sOldName])"
}
} | Set-Content -Path $sResultFile