title: Running foreach loop in powershell prompts for credentials every loop?
body: <p>I've implemented a short Powershell snippet to mass rename computers in my Domain. It reads a CSV file with two columns, OldName and NewName, and loops across the list to change the name.</p>
  <p>This works on paper, however every time I run the script it gives me a prompt to enter a password for every computer that it loops through. Is there a way to only use my credentials once for the whole script? Thank you.</p>
  <pre><code>$a = Import-Csv C:\File.csv -Header OldName, NewName
  Foreach ($Computer in $a) {Rename-Computer -ComputerName $Computer.OldName -NewName $Computer.NewName -DomainCredential Domain\Admin01 -Force -Restart}
  </code></pre>