powershell script to copy files from windows to multiple linux systems -


i trying copy file windows multiple linux machines using powershell script. list of machines read txt file. tried using pscp copy not work. issue here? there better way of doing this? thanks

$list = get-content c:\list.txt  foreach($host in $list) {    start-process 'c:\program files (x86)\putty\pscp.exe' -argumentlist ("-scp -pw mypasswd c:\patch.sh root@$host:/root/")     } 

in addition @obfuscate's note, $host reserved, read-only varible, might have issues root@$host:/root/ because of colon. colon namespace identifier variables. if need follow variable literal colon, should use curly braces.

try:

$list = get-content c:\list.txt  foreach($remotehost in $list) {    start-process 'c:\program files (x86)\putty\pscp.exe' `       -argumentlist ("-scp -pw mypasswd c:\patch.sh root@${remotehost}:/root/")     } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -