Advertisement
Guest User

Untitled

a guest
May 9th, 2018
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ChassiType = (gwmi Win32_SystemEnclosure).ChassisTypes
  2. $Nics = Get-WmiObject Win32_NetworkAdapterConfiguration
  3. foreach ($Nic in $Nics) {
  4.     write-host $Nic
  5.     if ($Nic.macaddress) {
  6.         $MACAddress = $Nic.macaddress
  7.         }
  8.    
  9.    
  10. }
  11. $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
  12. $newPCName = $MACAddress -replace ':',''
  13. $SN = gwmi win32_bios | Select โ€“ExpandProperty SerialNumber
  14. $paddedSN = $SN.padleft((12-$SN.lenght),"0")
  15.  
  16.  
  17. switch ($ChassiType){
  18.     {"3","4","6","7","13" -contains $_} {
  19.     #desktops
  20.     $OSDComputerName = "DSK" + $newPCName
  21.     $tsenv.Value("OSDComputerName") = $OSDComputerName
  22.     }
  23.     default{
  24.     $OSDComputerName = "LAP" + $paddedSN
  25.     $tsenv.Value("OSDComputerName") = $OSDComputerName
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement