Currently I have the below script that works however I have over 30 servers and they often change so i was curious if there was a simpler way to get the $ServerList
variable updated with the import data from each of my servers. The server path is the same and I could maintain a Server.txt
file with all the server names. Any ideas on how to simplify this to work with a larger list of servers that I can update when needed without having to add lines to the powershell script?
$Headers = "Extension","Server IP","Comment"
$1 = Import-Csv "\\Server1\app\test\Stations.txt" -Header $Headers | Select-Object *, @{n='Server Name';e={'Server1'}}
$2 = Import-Csv "\\Server2\app\test\Stations.txt" -Header $Headers | Select-Object *, @{n='Server Name';e={'Server2'}}
$3 = Import-Csv "\\Server3\app\test\Stations.txt" -Header $Headers | Select-Object *, @{n='Server Name';e={'Server3'}}
$4 = Import-Csv "\\Server4\app\test\Stations.txt" -Header $Headers | Select-Object *, @{n='Server Name';e={'Server4'}}
$ServerList = $1,$2,$3,$4