Author Posts

April 1, 2015 at 4:24 pm

i want to copy IIS logs from multiple app servers and dump them into one place. The script will run at the destination server. Hence, I wrote the script below. However, instead of going through one element in the array at a time, powershell treats everything as 1 element. How can I fix this issue? Any help would be appreciated,.

thanks

$unCA = "\\10.101.32.110", "\\10.101.32.111", "\\10.101.32.114", "\\10.101.32.115", "\\10.101.32.116", "\\10.101.32.117"
$unCB = "\\10.101.176.110"
$source = "C$\inetpub\logs\LogFiles\W3SVC1\*.log"
$destination = "E$\"
foreach ($element in $unCA) {
copy-item $uncA\$source $uncB\$destination
}

April 1, 2015 at 5:26 pm

This line:

copy-item $uncA\$source $uncB\$destination

Should probably be this:

copy-item $element\$source $uncB\$destination