Share via


PowerShell see's D:\RECYCLE.BIN folder path as a variable

Question

Friday, May 25, 2012 2:17 PM

Moved from http://social.technet.microsoft.com/Forums/en-US/windowsbackup/thread/e467b04a-be6b-4b1c-bbeb-5e15b8a8f27a/

I am trying to run a command in PowerShell for backup, but the folder path is interpreted as a variable. I tried single and double quotes and even a preceeding line of $BACKUP = '$BACKUP' but nothing works. It works fine using CMD.EXE. Here is the command and the warning. How can I get this to work correctly?

WBADMIN START BACKUP -backupTarget:\<server>\share>\folder> -include:D: -exclude:D:\RECYCLE.BIN -vssFull - quiet

Error:

WARNING - The file path 'D:\BIN' does not exist and will be ignored.

All replies (3)

Friday, May 25, 2012 2:45 PM âś…Answered | 1 vote

To reproduce your problem more simply, one could type this:

 cd c:\$RECYCLE.BIN

We then get the error you describe.  Instead, try this:

 cd c:\"$"RECYCLE.BIN

Mike Crowley | MVP
My Blog -- Planet Technologies


Wednesday, August 13, 2014 11:36 AM

This resolved my issue trying to clean the hidden recycle bin folder ! Thanks.


Saturday, December 19, 2015 7:41 PM

In PowerShell it will see the leading dollar sign character as meaning that 'RECYCLE' is a variable.  To tell PowerShell that the dollar sign character is a literal, prefix it with the backtick (grave accent character, to the left of the 1 digit on most keyboards) to escape the dollar sign so PowerShell won't try to interpret 'RECYCLE' as a variable.

PS C:\Windows\system32> cd c:\$Recycle.bin
PS C:\Recycle.bin>