Skip to content

How to set Computername with powershell in a MDT task sequence

Featured Replies

Hello!

 

Im trying to create a custom computer name when i deploy computers via MDT. What my goal is for example VM-last14numberofserialnumber.

 

I have created a script in powershell that almost do what i wan't:

 

Import-Module ZTIUtility
$y = Get-WMIObject Win32_BIOS | Select-Object SerialNumber; $tsenv:OSDComputerName= $y.Serialnumber.Substring(40,14).Replace(" ","")

At the moment the script makes only writes the last 14 numbers of the serialnumber and not the "VM-" before and that is what i wan't since I wan't to be able to control VM, DT (Desktop) or LT (Laptop) via customsettings.

 

Problem is, i don't know how i should handle this in a task sequence, I know that the script work because i created a custom task sequence with two tasks, One with this powershell script and one that writes "notepad.exe %OSDComputerName%" via CMD. So i get the result i wan't, but how to i actually set this to be my computername when i deploy a VM.

 

It is probaly pretty easy but im out of ideas.

 

Any tips or help is welcome.

 

// Anthon

  • Author

Hi,

Here is an example on how to do it http://www.potentengineer.com/using-powershell-to-set-osd-task-sequence-variables/

Regards,

Jörgen

 

Hello Jörgen!

 

Unfortunately i have already read this and i still don't understand. Like a said i got the script working and i have confirmed it via a MDT task sequence. What I need to understand is when the task sequence or WIndows PE sets the computer name so i can put my powershell script before that task. Hope you understand what i mean.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.