MichaelJLittle / PowerShell

Powershell
0 stars 0 forks source link

Auto backup a folder #13

Open MichaelJLittle opened 7 hours ago

MichaelJLittle commented 7 hours ago

Remove the existing backup folder if it exists

if (Test-Path "D:\projects") { Remove-Item -Recurse -Force "D:\projects" }

Copy the source folder to the destination

new-item -path "D:/" -name "Projects" -itemtype Directory; Copy-Item -Path "U:\01-michael\projects" -Destination "D:\projects" -Recurse

MichaelJLittle commented 7 hours ago

Remove the existing backup folder if it exists

if (Test-Path "D:\projects") { Remove-Item -Recurse -Force "D:\projects" }

Copy the source folder to the destination

new-item -path "D:/" -name "Projects" -itemtype Directory; Copy-Item -Path "\tb-dc02\SHARED\01-michael\projects" -Destination "D:\projects" -Recurse

if you pull from a network drive, the path must be how it is set in the server share, not using the drive letter name. or else it won't work