title: Changing Multiple Host Names on Domain using PowerShell
body: <p>Trying to create a PowerShell script to change the name of about 300 machines to match one naming scheme. I have figured out a way to do this through PS but only one-by-one and that's just not going to cut it.</p>
  <p>Current Process:</p>
  <pre><code>Get-WMIObject Win32_Bios -ComputerName 'hostname' | Select-Object SerialNumber
  </code></pre>
  <p>Followed by: (Using the last 5 of the serial)</p>
  <pre><code>RenameComputer -ComputerName &quot;curretHostName&quot; -NewName &quot;TEST-(last 5)&quot; -DomainCredential xxxxx
  </code></pre>
  <p>Thought process is creating an array using:</p>
  <pre><code>$ComputerNames += Get-ADComputer -Filter 'Name -like &quot;*&quot;' | FT Name -A
  </code></pre>
  <p>Then using a ForEach loop on each name in the $ComputerNames array. But this is where I am stuck. I was trying to start small and just get the return of the SerialNumbers and go from there. This is my current ISE that's not working.</p>
  <pre><code>$ComputerNames += Get-ADComputer -Filter 'Name -like &quot;testComputerName&quot;' | FT Name -A
  ForEach ($name in $ComputerNames)
      {
         Get-WMIObject Win32_Bios -ComputerName '*' | Select-Object SerialNumber
         }
  </code></pre>
  <p>This is the first big thing I have done with PS btw so this has been a lot to take in!</p>
  <p>Any advice is greatly appreciated. This task was handed to me this morning so it’s fresh. Thanks everyone :)</p>