Jump to content


coolslim54

SCCM OSD Computer Name Change

Recommended Posts

Currently running SCCM 1511 with MDT 2013 integrated. We are looking to refresh all machines (desktops and laptops) from Win 7 to Win 10. My MDT Task Sequence works well, but I'm looking for a way to change the first 3 characters of the computer names. We have a standard naming convention, Example: current name looks like TW7NSDA-002-0000. The TW7 reflects Win 7. Is there a simple script I can implement in the Task Sequence to change TW7 to TW10 so the new computer name would reflect TW10NSDA-002-0000? Thanks!

Share this post


Link to post
Share on other sites

This should work (I haven't tested it because im not at work atm)

$var = New-Object -ComObject Microsoft.SMS.TSEnvironment
$OSDComputerName = $var.Value("OSDComputerName")
$var.Value("OSDComputerName") = ($OSDComputerName).Replace("TW7", "TW10")

Share this post


Link to post
Share on other sites

It worked for me doing it during the task sequence. As YPCC said if you just run the script while in the OS then it wont work as the com object (Microsoft.SMS.TSEnvironment) wont be able to load. If you run it during the task sequence then it will work.

 

And make sure you running it as a PowerShell script during the task sequence.

Share this post


Link to post
Share on other sites

Tregelen,

 

If I wanted to add an additional line in the script to reflect laptops, could I just add the line at the end to look like this

 

  1. $var = New-Object -ComObject Microsoft.SMS.TSEnvironment
  2. $OSDComputerName = $var.Value("OSDComputerName")
  3. $var.Value("OSDComputerName") = ($OSDComputerName).Replace("TW7", "TW10")
  4. $var.Value("OSDComputerName") = ($OSDComputerName).Replace("LW7", "LW10")

Or would I need to add and elseif statement? I would think that it would ignore line 3, if nothing matches with what the script is looking for....

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
Reply to this topic...

×   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.