Dell: Rename-Computer -NewName ("CNHZPD-" + (Get-WmiObject -class win32_Bios).SerialNumber.substring(0,7)) -Restart Lenovo: $parttern_ln="D{2}d{8}" $parttern_tp="w{7}" $biosname = (Get-WmiObject -Class win32_Bios).serialnumber $baseboardname = (Get-WmiObject -Class win32_BaseBoard).serialnumber if ($biosname -match $parttern_ln) { Rename-Computer -NewName ("CNHZLN-" + $biosname.Substring(2,8)) -Restart } elseif($baseboardname -match $parttern_ln) { Rename-Computer -NewName ("CNHZLN-" + $baseboardname.Substring(2,8)) -Restart } elseif($biosname -match $parttern_tp) { Rename-Computer -NewName ("CNHZLN-" + $biosname) -Restart } else {Write-Host "Sorry"}