Need to create a script to copy the latest version of a folder to an external drive.


hi all,

im quite new powershell, trying create script run each sunday copy our directory external drive. 

$backup2 = "v:\xxxxx\xxxxxxx 2014-12-13 08;03;56 (full)\*"
$dest = "b:\"

copy-item -path $backup -destination $dest

only problem folder change name every week. 
how run without modifying script each week?

thanks in advance.

you go level , grab folder latest lastwritetime, should ensure ever newest folder - 

$path  =  (gci <path> | sort lastwritetime -descending | select -index 0).fullname



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2