OK, I thought that’s what you wanted.
It’s just a case of adapting the regular expression to match (no pun intended) your requirements:
$data = Import-CSV E:\Temp\Files\List-SourceNames-OLD.csv
$latest = Get-Content E:\Temp\Files\latest.txt
foreach ($update in $latest) {
$update -match '(.+)(\d{5}\.\d+\s\d+$|\d{5}\.\d+)' | Out-Null
$entry = ($data.osd_name | Where-Object {$_ -like "$($matches[1])*"})
$index = $data.osd_name.IndexOf($entry)
$data[$index].osd_name = $data[$index].osd_name -replace '(\d{5}\.\d+)',$matches[2]
}
$data
Output:
src_name osd_name
-------- --------
Windows 10 Enterprise LTSC 2021 Windows 10 Enterprise LTSC 2021 x64 21H2 19044.1586
Windows 10 Pro for Workstations Windows 10 Pro for Workstations x64 21H2 19044.1586
Windows 11 Pro for Workstations Windows 11 Pro for Workstations x64 21H2 22000.556
Windows 11 Pro Windows 11 Pro x64 21H2 22000.556
Windows Server 2022 Datacenter (Desktop Experience) Windows Server 2022 Datacenter Desktop Experience x64 Dev 22509.1200 2203140144
Windows Server 2022 Datacenter Windows Server 2022 Datacenter x64 Dev 22509.1000 2203140148