for example:
$servers = import-csv servers.csv
foreach ($server in $servers) {copy-item $server.namec$test.txt -destination c:backup$server.name}
the issue is the that $server.name does NOT replace it with the real server name.
if I do:
foreach ($server in $servers) {$server.name}
the $server.name is look OK and I get the list of all SERVERS in the csv file
I need to put the servers as part of the path - ho do I do that ?
TIA
how to put $ inside path ?
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
how to put $ inside path ?
for example:
$servers = import-csv servers.csv
foreach ($server in $servers) {copy-item $server.namec$test.txt -destination c:backup$server.name}
the issue is the that $server.name does NOT replace it with the real server name.
if I do:
foreach ($server in $servers) {$server.name}
the $server.name is look OK and I get the list of all SERVERS in the csv file
I need to put the servers as part of the path - ho do I do that ?
TIA
$servers = import-csv servers.csv
foreach ($server in $servers) {copy-item $server.namec$test.txt -destination c:backup$server.name}
the issue is the that $server.name does NOT replace it with the real server name.
if I do:
foreach ($server in $servers) {$server.name}
the $server.name is look OK and I get the list of all SERVERS in the csv file
I need to put the servers as part of the path - ho do I do that ?
TIA
how to put $ inside path ?
Try this:
foreach ($server in $servers) {copy-item $($server.name)c$test.txt -destination c:backup$($server.name)}
foreach ($server in $servers) {copy-item $($server.name)c$test.txt -destination c:backup$($server.name)}
how to put $ inside path ?
little better but still I get this message:
Copy-Item : A parameter cannot be found that matches parameter name 'server-name'
(in the error message the 'server-name" is the correct name but still....what is that error?
Copy-Item : A parameter cannot be found that matches parameter name 'server-name'
(in the error message the 'server-name" is the correct name but still....what is that error?