The Realm of the Verbal Processor

Jarvis's Ramblings

PowerShell Script – Loop

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.

October 28, 2009 - Posted by | scripting

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: