path does not recognize $env:username as part of the path?

by Oct 25, 2011

Hi people,

I'm trying to complete my underneath script but I do not succeed to put the $env:username as part of the path. Can anyone help with this?

powershell $usr = $env:username
powershell COPY-Item 'C:Users$usrAppDataLocalLocal Documents – No Backup*' -Destination 'A:$usr' -Recurse -force
Powershell Remove-Item 'C:Users$usrAppDataLocalLocal Documents – No Backup*' -recurse -force


This is the error output I receive:
Copy-Item : Cannot find path 'C:Users$usrAppDataLocalLocal Documents – No Backup' because it does not exist.
At line:1 char:10
+ COPY-Item <<<<  'C:Users$usrAppDataLocalLocal Documents – No Backup*' -Destination 'A:$usr' -Recurse -force
    + CategoryInfo          : ObjectNotFound: (C:Users$usrA…nts – No Backup:String) [Copy-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand