User Back up function or Script

 

First I want to point out the $home variable for individual self initiated back ups.

so if you wanted to back up specifics to the current logged in user $home is Sufficient, even if you have DFS / or SMB redirected home folders.

if you are backing up all users you need to also save the sticky notes. that’s an added bonus to reading my article.

Function Get-Backup ($user){

# Get logged on Username
if ($User -like $null) {$User = $env:username}

Create path using variables so that we arent guessing usernames.
$path = "\\Server\Users\$user\user_backup\$(Get-Date -Format M)\"

#create newer Path based on the date.
new-item -ItemType directory -Path $path -ErrorAction SilentlyContinue
$logged ="$path\Results.txt"

#copy contents of vital folders specified below from there paths to the new location.

copy-item c:\users\$user\pictures -recurse -Destination $path -ErrorAction SilentlyContinue
copy-item c:\users\$user\documents -recurse -Destination $path -Verbose -ErrorAction SilentlyContinue
copy-item c:\users\$user\downloads -recurse -Destination $path -Verbose -ErrorAction SilentlyContinue
copy-item c:\users\$user\favorites -recurse -Destination $path -Verbose -ErrorAction SilentlyContinue
copy-item c:\users\$user\links -recurse -Destination $path -Verbose -ErrorAction SilentlyContinue
copy-item c:\users\$user\desktop -recurse -Destination $path -Verbose -ErrorAction SilentlyContinue
copy-item c:\users\$user\music -recurse -Destination $path -Verbose -ErrorAction SilentlyContinue
copy-item c:\users\$user\contacts -recurse -Destination $path -Verbose -ErrorAction SilentlyContinue
# I only included these folders because these are standard folders anything extra needs to be added manually.

I know a lot of people who are attached to their sticky notes.
located here:
$notes= ls "C:\Program Files\WindowsApps\microsoftstickynotes*"
copy-item $notes.fullname $path -Verbose -ErrorAction SilentlyContinue
}#End Function  you can always make this much more robust.

 

Enjoy City Life? I grew up in the city and I rather not deal with heavily populated areas. although I prefer people than bugs that goes for computer bugs too lol

Published by Xajuan Smith

Computer Information Specialist, with a desire to make the masses feel what I was born to channel...The emotion that strives us to do more, speak more boldly and with most sincere ideals that will make life easier and will not hinder the dreams we all have at any given time.

One thought on “User Back up function or Script

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.