Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

SOLVED I am looking for a script that will change only the first few characters of a computer name.

  • Thread starter Thread starter doadea
  • Start date Start date
  • Replies Replies 1
  • Views Views 961

doadea

New Member
Messages
2
Reaction score
0
Points
1
I am looking for a script that will change only the first few characters of a computer name.
For example:
I have hundreds of machines named "w2k19-xxx" in my environment
like w2k19-500 for example
I want to change it to w2k22-500. I want to change the "w2k19" part to "w2k22" but keep the rest of the name as is.
I can push the script with SCCM I am hoping. Everything I have found so far does not work. Any help would be appreciated.
 
Code:
$newHostname = $env:computername.replace("w2k19","w2k22")
Rename-Computer -NewName $newHostname

Nothing hard. Hope this helps you find the right way.
 

Forum statistics

Threads
7,196
Messages
28,081
Members
18,354
Latest member
davidluong

Trending content

Back
Top