The Realm of the Verbal Processor

Jarvis's Ramblings

PowerShell Script – Loop

Posted by Jarvis on October 28, 2009

Rick emailed me asking the following question about the PowerShell script I wrote last year for adding a domain user to the local admin group on a computer.

How would I loop thru the script for multiple machines ? i.e how to add an account to the local admin groups to a list of systems in a csv

Short answer is you need to look using two PowerShell cmdlets in conjunction. They are:

  • Import-CSV
  • ForEach-Object

You can read about them and a bit about how to use them here, and here. Additionally, I would refer anyone with scripting questions to check out the Scripting Guys blog…it is fantastic.

Hope that helps.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>