$backupfolder = "\\server\somefolder1\somefolder2\"
$localpath="C:\Documents and Settings\myname\My Documents\FilestoCopytoServer\folder1\"
foreach ($dir in $localpath)
{
write-host $dir
if(test-path $dir.fullname -pathtype container)
{
write-host "it a directory"
write-host "check if this directory is in the remote machine or not"
$direxists = test-path $remotepath\$dir -pathtype container
if($direxists)
{
write-host "remote machine has this directory"
recurseandcopyfiles($dir)
}
else
{
write-host "directory does not exist so create directory"
createdir($remotepath,$dir)
}
}
else
{
write-host "it not a container so copy files"
write-host $dir "and backup folder is " $backupfolder
backup( $dir,$backupfolder)
}
}
function backup($source,$destination)
{
write-host "inside backup"
write-host "source is " $source "and destination" is $destination
#this is showing I'm getting following:
# source is file1.txt \\server\somefolder1\somefolder2\
}
$localpath имеет file1.txt, поэтому первым параметром для функции резервного копирования является file1.txt. Функция резервного копирования имеет два параметра, но первый параметр получает как переданные значения. В чем проблема?