Quantcast
Channel: Ivanti User Community: Message List
Viewing all articles
Browse latest Browse all 13696

PowerShell task to name computer from Service Tag during Provisioning

$
0
0

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!


Viewing all articles
Browse latest Browse all 13696

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>