1

I am having to create a solution to backup user profiles on a domain (not VDI's) I have the following script that I got to copy the favorites folder, the issue I am having is that I need the script to create a folder based on the username of the person we are backing up and then copy the profile to the folder that was created (based on the username)

I am new on the powershell scripting and haven't been able to find any other solution that does not require the purchase of software.

$destination = "\\backupserver\homedrive$\" 
Copy-Item $env:USERPROFILE\Favorites -Destination $destination -Recurse -Force
  • 1
    If $env:USERPROFILE returns the value of the system variable %USERPROFILE%, how might one access other system variables in PowerShell? – jscott Feb 12 '16 at 18:22
1

If you want to copy the entire user's profile folder, that should include the 'Favorites' folder as well. If that is the case, you could use this.

$destination = 'some destination path'
Copy-Item $env:userprofile -destination $destination -Recurse -force

That should create a folder based on the username.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.