hello
i have a job script that work perfectly when the sourceparth is not a variable in the copy-item like this,
copy-item c:\source "\\$ip\c$" -Recurse , but when i set $sourcepath="c:\$folder", the job does not start any more
#begin script
$folder= read-host "enter source folder name"
$sourcepath="c:\$folder"
$jobs = foreach ($ip in gc C:\cmp.txt) {
Start-Job -Name "Copyjob to $ip" -ArgumentList $ip -ScriptBlock {
param($ip)
if (Test-Connection -ComputerName $ip -Count 1 -Quiet)
{
copy-item $sourcePath "\\$ip\c$" -Recurse
}
}
}
$jobs | Wait-Job
any idea...?
thanks