User Back up function or Script

See the source image

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

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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