Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


PowerShell Code - back up folder.

  • Please log in to reply
1 reply to this topic

#1 teatrap


  • Members
  • 121 posts
  • Gender:Male
  • Local time:02:24 AM

Posted 01 January 2014 - 04:29 PM

How do, I've got a little script that just copies a folder from my DropBox onto my desktop. 
here's the script : 

Copy-Item -recurse "C:\Users\USER NAME\Dropbox\COMPANY NAME\synced dropbox" "C:\users\USER NAME\Desktop\COMP Files Backup"

It works, and it run's through the task scheduler... But what I wanted to do was add the date to the new folders name so that the next time the script was run it didn't flag as an error (because the folder already exists)


I tried (stab in the dark) 

$_date = Get-Date
Copy-Item -recurse "C:\Users\USER NAME\Dropbox\COMPANY NAME\synced dropbox" "C:\users\USER NAME\Desktop\COMP Files Backup $_date" 

but that doesn't work... If anyone could point me in the right / a direction that'd be ace. 

Operating system_Windows 8.1 Pro with Media Center (9600)
CPU_Intel® Core™ i7-4700MQ CPU @ 2.40GHz
Motherboard_Hewlett-Packard (1966)
Hard Drive_931gb (HGST HTS541010A9E680)
Graphics card_Intel® HD Graphics 4600
Sound card_IDT High Definition Audio CODEC

BC AdBot (Login to Remove)


#2 Sirawit


    Bleepin' Brony

  • Malware Response Team
  • 4,163 posts
  • Gender:Male
  • Location:Thailand
  • Local time:08:24 AM

Posted 01 January 2014 - 10:57 PM

I have no experience with powershell, but in psuedocode, it will be something like this:

$_date = Get-Date
Copy-Item -recurse "C:\Users\USER NAME\Dropbox\COMPANY NAME\synced dropbox" "C:\users\USER NAME\Desktop\COMP Files Backup" &$_date #assume & char is like in VB.

In your above code, "date" variable is a part of the string. In this case the folder name will always be COMP Files Backup $_date because it can't retrieve variable data.


You need to combine "folder name" and "date" before put it in copy command.


Thank you.

Edited by Sirawit, 01 January 2014 - 10:57 PM.

If I don't reply back to you in 2 days, feel free to send me a PM.


“You’re lying… just like you were lying to me before. You have to hate me. I’ve been the worst daughter in the world… you should hate me.”

“But I don’t, Nyx. Because, Nyx, I’m your mother, and a mother will always love her daughter, no matter what.” -Past sins by Pen stroke.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users