Copy-File (Robocopy) hiding destination folder in PSADT 3.10.1

When using Copy-File, Robocopy is used by default instead of Copy-Item in recent PSADT versions (3.10.x).
There seems to be a known bug in Robocopy which sometimes hides the destination folder. I experienced this when copying a .lnk file from the $envCommonDesktop to $envCommonStartMenuPrograms. After testing it seems to always occur when you copy anything from the public desktop to any destination.
In 3.10.1 there are override parameters for Robocopy so I solved it by using -RobocopyAdditionalParams '/A-:SH' to fix this:

Copy-File -Path "$envCommonDesktop\AutoCAD Architecture 2024 - English (Swedish).lnk" -Destination "$envCommonStartMenuPrograms\AutoCAD Architecture 2024 - English\" -RobocopyAdditionalParams '/A-:SH'

3 Likes

Thanks for this, I will take a good look and see if it’s worth implementing that switch as default!

3 Likes

I can reproduce this; it copies over the attributes from the source folder to the destination folder.

The file itself being copied does not have its attributes changed, and adding /A-:SH does not stop the destination folder from having its attributes altered. Also, adding that switch would strip off the hidden/system attributes that you might want to retain.

Instead I will look to try and backup/restore the attributes of the destination folder before and after running Robocopy.

1 Like

Fix implemented ( Copy-File fixes by DanGough · Pull Request #1015 · PSAppDeployToolkit/PSAppDeployToolkit (github.com)) and will be part of our final (we hope) release for v3.x.

1 Like