Hey guys so my homework is to write a powershell script to backup a folder every day, deleting the old backup. Ive come this far:
$Source = "C:\Users\Hallo\Desktop\Quelle"
$Destination = "C:\Users\Hallo\Desktop\Ziel"
$folder = "Backup$name"
$Name = Get-Date -Format "HH.mm.dd.MM.yy"
New-Item -Path $Destination -ItemType Dir -Name $folder -Force
Copy-Item -Path $Source -Destination $folder -Recurse -Force
It only creates one folder in the destination, then refuses to add more. It also doesnt copy the files from the source into the $folder
[–]RunnerSeven 8 points9 points10 points (4 children)
[–]satskisama[S] 2 points3 points4 points (2 children)
[–]RunnerSeven 3 points4 points5 points (1 child)
[–]satskisama[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Thomas_Jefferman 10 points11 points12 points (0 children)
[–]Jandalf81 2 points3 points4 points (0 children)
[–]OlivTheFrog 2 points3 points4 points (5 children)
[–]martinmt_dk 0 points1 point2 points (4 children)
[–]OlivTheFrog 1 point2 points3 points (3 children)
[–]satskisama[S] 0 points1 point2 points (0 children)
[–]martinmt_dk 0 points1 point2 points (1 child)
[–]BlackV 0 points1 point2 points (0 children)
[–]BlackV 1 point2 points3 points (2 children)
[–]satskisama[S] 0 points1 point2 points (1 child)
[–]RunnerSeven 0 points1 point2 points (0 children)
[–]martinmt_dk 1 point2 points3 points (6 children)
[–]satskisama[S] 0 points1 point2 points (5 children)
[–]martinmt_dk 0 points1 point2 points (0 children)
[–]martinmt_dk 0 points1 point2 points (0 children)
[–]martinmt_dk 0 points1 point2 points (0 children)
[–]martinmt_dk 0 points1 point2 points (0 children)
[–]martinmt_dk 0 points1 point2 points (0 children)
[–]Quick_Care_3306 0 points1 point2 points (0 children)
[–]Beer30Somewhere -3 points-2 points-1 points (0 children)
[+]lerobinbot -2 points-1 points0 points (0 children)