Param( $source='server01.local\c$\temp\', $path='c$\Program Files\VMware\VMware tools', $files='tools.conf', $faillog='c:\temp\failed.csv', $successlog='c:\temp\success.csv' ) $ServerArray=$(Get-Content \\$source\host_list.csv) foreach ($ServerName in $ServerArray) { Copy-Item \\$source\$files -Destination \\$ServerName\$path -force -ErrorAction "SilentlyContinue" If ($Error) {Write-Output $ServerName | out-file -append -encoding default $faillog; Write-Host "$ServerName is failed copied $files" -foregroundcolor "magenta"} Else {Write-Output $ServerName| out-file -append $successlog; Write-Host "$ServerName is successfully copied $files"} $error.clear() } |