Author Posts

October 26, 2015 at 12:28 pm

OK so here is the short and sweet...

$d=get-date -Uformat %Y%m%d
robocopy.exe C:\$folder D:\$folder /LOG:Log_$folder_$d.txt

For some reason the file name of the log ends up being "Log_20151026.txt". The folder name does not get included in the log. If I remove the $d (/LOG:Log_$folder.txt). The log will be "Log_TestFolder". What am I missing here? What needs to be changed so that the log file will be "Log_TestFolder_20151026.txt"?

October 26, 2015 at 12:39 pm


PowerShell is assuming the underscore is part of the name of the variable. Try this:


October 26, 2015 at 12:48 pm

Thanks Tim for the prompt reply! That is exactly what I was looking for. 🙂