5 Replies Latest reply on Mar 25, 2014 2:41 PM by NeoIsTaken

    PowerShell task to name computer from Service Tag during Provisioning

    jwood8 Apprentice

      Hi all,

       

      Just a quick one to give something back - we wanted to automatically name our stations to the service tag when provisioning. Here's a simple PowerShell script which you can save as rename.ps1 or something and then just add as a PowerShell distribution package and set as a provisioning step. Tested and works on all our Dell machines with Windows 7 and latest PowerShell, other manufacturers may vary but worth a go.

       

      $computername = Get-Content env:computername

      $servicetag = Get-WmiObject win32_bios | Select-Object -ExpandProperty SerialNumber

      If ($computername -ne $servicetag)

                {

                Write-Host "Renaming computer to $servicetag..."

                Rename-Computer -NewName $servicetag

                }

      Else

                {

                Write-Host "Computer name is already set to service tag, nowt to do!"

                }

       

      Hope this helps!