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

smartface.io - Proper way to change color scheme for whole application -

javascript - three.js lot of meshes optimization -

Email notification in google apps script -