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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章