我需要使用PowerShell脚本备份我的userprofile。我已经以某种方式工作,但当副本完成输出看起来真的很奇怪。没有生成新文件夹。
输出:
$Destination = Read-Host "Please type the path directory you want to copy the backup files" #destination
$Folder = Read-Host "Please type the root name folder" #name of backup folder
$validation = Test-Path $Destination #validate the destination if it has the privileges
New-PSDrive -Name "Backup" -PSProvider FileSystem -Root $Destination #temporary folder for the backup
New-Item -ItemType directory -Path $Destination\$Folder
if ($validation -eq $true) {
Set-Location Backup:
} else {
Write-Host "Error!Run Script Again"
break
}
robocopy "$env:UserProfile\desktop\" $Destination\$Folder *.* /mir /sec
robocopy "$env:UserProfile\pictures\" $Destination\$Folder *.* /mir /sec
robocopy "$env:UserProfile\documents\" $Destination\$Folder *.* /mir /sec
function Pause {
Write-Host "Backup Sucessfull!!! `n"
}
Pause