我遇到了一个应该作为备份替换的脚本的问题。这只是漏洞的一部分,其他东西有效但依赖于它。
$datum = get-date -uformat "%Y-%m-%d"
$backupsrv = "\\192.168.0.5\"
$logpath = "$backupsrv\logs\$datum"
$test1 = "d:\test1","$backupsrv\b2d\test1","Test1"
$test2 = "c:\test2","$backupsrv\b2d\test2","Test2"
$programs = ($test1,$test2)
if (!(test-path -path $logpath))
{new-item $logpath -type directory}
function backup{
param
(
[Parameter(Position=0,Mandatory=$true)]
[String] $Source,
[Parameter(Position=1,Mandatory=$true)]
[String] $Target,
[Parameter(Position=2,Mandatory=$true)]
[String] $Name
)
if (!(test-path -path $target))
{new-item $target -type directory}
$LogFile = "$logpath\$name.log"
robocopy "$Source" "$Target" /e /mir /np /ns /z /r:3 /w:30 /xf thumbs.db >>$logfile
}
foreach ($program in $programs){
backup $program}
参数处理总是出错。
谁能帮我解决这个问题?谢谢!!