Jump to content


  • 0
stylaren

How to set Computername with powershell in a MDT task sequence

Question

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

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.