欢迎光临
我们一直在努力

Powershell:powershell脚本同步备份文件到其他服务器

Remove-PSDrive Z

$User = "192.168.1.1\administrator"
$PassWord = ConvertTo-SecureString -String "Passw@rd" -AsPlainText -Force
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PassWord
New-PSDrive -Name Z -PSProvider FileSystem -Root \192.168.1.1\Backup -Persist -Credential $Credential
$timelabe = Get-Date -UFormat "%Y-%m-%d-%H-%M"
Get-date -uformat "%c" >> d:\log\$timelabe.log
echo "Starting synchronize files…" >> d:\log\$timelabe.log
robocopy D:\Backup Z:\ /mir >> d:\log\$timelabe.log
Get-date >> d:\log\$timelabe.log

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。