@tim_g said in PowerShell Regex - How to remove everything after first line?:

Actually, I'm sticking to this:

$compName = Get-WmiObject win32_ComputerSystem | Select-Object -ExpandProperty Name if ($compName -match "WINDOWS") { $dellTag = Get-WmiObject win32_bios | Select-Object -ExpandProperty SerialNumber Rename-Computer -NewName $dellTag -Force -Restart } Exit

Compared to sed, that makes my head hurt. Glad you got it sorted, and an example for when I'll need to do the same thing.