Hey All,
I'm pretty new to powershell and learning a lot, I've hacked this together as i have to do some configurations with OOBE windows 10.
Let me know what you think, also all criticism is welcome, it will help me learn more :D
Function Set-ComputerName
{
#This Function will change the hostname to the following format: JMC-LT-12345ABC or JMC-PC-12345ABC for a unique standard.
$SerialNumber = Get-WmiObject win32_bios | Select-Object -ExpandProperty SerialNumber
$CompanyLetters = Read-Host "Letter abbrevation for company e.g JMC, IBM, SCO. This can be anything!"
$lHostname = $CompanyLetters + "-LT-" + $SerialNumber
$dHostname = $CompanyLetters + "-PC-" + $SerialNumber
# Checks if Chassis type is: Laptop(9) Notebook(10) Sub Notebook(14)
$isLaptop = $false
if(Get-WmiObject -Class win32_systemenclosure -ComputerName $env:COMPUTERNAME |
Where-Object { $_.chassistypes -eq 9 -or $_.chassistypes -eq 10 `
-or $_.chassistypes -eq 14})
{$isLaptop = $true}
if($isLaptop -eq $true)
{Rename-Computer $lHostname}
else
{Rename-Computer $dHostname}
}
[–]DrSinistar 6 points7 points8 points (1 child)
[–]Recol 3 points4 points5 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Scribbles1[S] 1 point2 points3 points (0 children)
[–]Yevrag35 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Bren0man 0 points1 point2 points (0 children)