Adding Powershell variables
Posted on 2012-04-09
I'm putting together a Powershell script to collect event log data from servers. It works fine when I use -ComputerName . or I actually input the name of the server.
However, I have a CSV with the name of each server and I'd like to have it go through each server name in the CSV individually and add the result to a text file I have it create so I can look at the event log info.
When I use $ComputerName = import-CSV C\Temp\ServerEventLog.csv it adds the entire list of servers to the variable. I need to have it take one name, collect the event logs and then go to the next server name in the list, so that the variable $ComputerName changes as it finishes collecting the eventlog and moving to the next server in the list?
Is this possible? Seems like it should be but I'm at a loss. I've attached as a text file the very simple script I'm working on.