title: How will I save my credentials every loop in Powershell
body: <p>Is there a way in saving my credentials so it will not keep asking every loop? Like, isolating it outside the foreach loop. I tried removing <code>-credentials</code> and add it outside but it gives me an error of unauthorized access. I can't seem to figure it out. Sorry if this question seem to be stupid, I'm new to Powershell.</p>
  
  <pre><code>Import-Module ActiveDirectory
  
  $ServerList = Get-Content "C:\servers.txt"
  
  foreach($ServerName in $ServerList){
  
  "$ServerName"
  "=========="
  Get-WmiObject -Class Win32_UserAccount -Computer $ServerName -Filter "LocalAccount='True'" -credential CORPORATE\usmenm03adm| Select Name
  
  " "
  
  }
  </code></pre>