Skip to content

SCCM OSD Computer Name Change

Featured Replies

That will work, or you could add in an additional .Replace on the same line. It technically wont skip that line, it will still run it it just doesnt find that string to replace.

$var = New-Object -ComObject Microsoft.SMS.TSEnvironment
$OSDComputerName = $var.Value("OSDComputerName")
$var.Value("OSDComputerName") = ($OSDComputerName).Replace("TW7", "TW10").Replace("LW7", "LW10")
  • 4 months later...
  • Replies 21
  • Views 19.6k
  • Created
  • Last Reply

Top Posters In This Topic

Posted Images

  • Author

Tregelen,

It's me again! The script you provided above works great! Just one last step. How can I remove the first dash from TW7NSDA-002-0000? Again, many thanks!

Try this

$var = New-Object -ComObject Microsoft.SMS.TSEnvironment
[regex]$pattern = "-"
$var.Value("OSDComputerName") = ($pattern.replace($var.Value("OSDComputerName"), "", 1)).Replace("TW7", "TW10").Replace("LW7", "LW10")

 

 

  • Author

Gave it a shot and the task sequence failed at powershell script step with error code 0xFFFD0000. Do I need to set the OSDComputerName variable like before?

$OSDComputerName = $var.Value("OSDComputerName")

That is interesting, it worked for me. Are you running it as 'Bypass' in the TS step?

Are you able to F8 and do the steps manually? I was just able to do the commands in my VM and it worked fine.

MachineRename.png.ebd69b81314e797fbbe9e14c3a624648.png

 

I will try it as a step instead of manually and see if I get the same result.

  • Author

Definitely running the script as bypass in the task sequence. I'll try the manual steps tomorrow at work. Thx!

Ok, I will see what I can work out with it and get back to you.

  • Author

I also tried the following and received the same error mentioned above in my task sequence:

$var = New-Object -ComObject Microsoft.SMS.TSEnvironment
[regex]$pattern = "-"
$OSDComputerName = $var.Value("OSDComputerName")
$var.Value("OSDComputerName") = ($pattern.replace($var.Value("OSDComputerName"), "", 1)).Replace("TW7", "TW10").Replace("LW7", "LW10")
  • 2 weeks later...

If you wish to rename prior to OSD within windows you could do it through WMIC command. This will allow you to remove the dashes as needed.

The only downside is that you will need to create a extensive batch file if a large amount of PCs needs to be changed, oldname and new desired name but with excel you can do this easily and export.

Syntax

WMIC ComputerSystem where Name="XX-XXX-PC01" call Rename Name="AABBB-PC01"

WMIC ComputerSystem where Name="XX-XXX-PC01" call Rename Name="BBCCC-PC01"

WMIC ComputerSystem where Name="XX-XXX-PC01" call Rename Name="CCDDD-PC01"

 

Create a package with batch file as above - create custom TS and copy script locally to all desired PCs from within the TS then use run command line to execute batch file locally at each PC and use an account that has domain rights to execute script in run command line. Place restart command in TS and then you could do another run command line to execute a DDR to update the CMDB with new names when the systems start backup from previous restart.

WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000003}" /NOINTERACTIVE

execute a delay of a 2-3 minutes so that the systems has time to update information to site server after the DDR has executed and then do another restart to update the DNS records of each systems change if you want remote control to work immediately etc... You'll need to update the collections in the console after all is finished to reflect name changes.

Not the most convenient way of achieving this but will work - and works in windows which is a bonus.

 

 

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.