Reputation: 747
I have a code running at the moment that pulls data from a txt file . But I decided not to take all the values from a separate list,i want to implement these values direct into the code
$SERVERS = gc "C:\Users\listofSERVERS.TXT "
Rather have all values in the code
$SERVERS =( echo "Server1, Server2, Server3 ..." )
But the code is returning an empty file. Not sure if I am assigning $SERVERS variable correctly.
Upvotes: 1
Views: 30
Reputation: 27463
The doublequotes make it a single string. It could be as simple as:
$SERVERS = echo Server1 Server2 Server3
Upvotes: 2
Reputation: 2415
If you want an array of servers you can use something like the below. Note that it will only print out the current server to the console :)
$servers = @("Server1","Server2","Server3")
Foreach($server in $servers){
Write-Host $server
}
Upvotes: 1