$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's 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's 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。函数备份有两个参数,但第一个参数获取两个传递的值。这里有什么问题?