coolslim54 Posted August 27, 2016 Report post Posted August 27, 2016 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! Quote Share this post Link to post Share on other sites More sharing options...
tregelen Posted August 28, 2016 Report post Posted August 28, 2016 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") Quote Share this post Link to post Share on other sites More sharing options...
coolslim54 Posted August 30, 2016 Report post Posted August 30, 2016 Thanks! I'll give it a shot! Quote Share this post Link to post Share on other sites More sharing options...
coolslim54 Posted October 22, 2016 Report post Posted October 22, 2016 Tregelen, did you ever get a chance to test it? I tested the script before adding it to my task sequence and it came back with errors. Quote Share this post Link to post Share on other sites More sharing options...
YPCC Posted October 22, 2016 Report post Posted October 22, 2016 How did you test it? It has to be run with the Task sequence environment (New-Object -ComObject Microsoft.SMS.TSEnvironment), so if all you did was run the VBS in windows that it wouldn't work. Quote Share this post Link to post Share on other sites More sharing options...
tregelen Posted October 23, 2016 Report post Posted October 23, 2016 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. Quote Share this post Link to post Share on other sites More sharing options...
coolslim54 Posted October 24, 2016 Report post Posted October 24, 2016 Thanks for your responses. My PowerShell skills are terrible at the moment, but I'm working on it...I'll give it a shot and follow up. Thanks again! Quote Share this post Link to post Share on other sites More sharing options...
coolslim54 Posted October 25, 2016 Report post Posted October 25, 2016 Man, you guys are "da truth"!! Script worked like a charm! Many thanks! I'll definitely be keeping that one. Quote Share this post Link to post Share on other sites More sharing options...
tregelen Posted October 25, 2016 Report post Posted October 25, 2016 Happy to help Quote Share this post Link to post Share on other sites More sharing options...
coolslim54 Posted November 11, 2016 Report post Posted November 11, 2016 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 $var = New-Object -ComObject Microsoft.SMS.TSEnvironment $OSDComputerName = $var.Value("OSDComputerName") $var.Value("OSDComputerName") = ($OSDComputerName).Replace("TW7", "TW10") $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.... Quote Share this post Link to post Share on other sites More sharing options...