Copy-FileToUserProfiles not copying all files


I am trying to copy a folder called Sun from the Support Files folder to Appdata\Roaming using the Copy-FileToUserProfiles function. I am using the command below

Copy-FileToUserProfiles -Path "$dirFiles\Sun" -Destination "AppData\Roaming\Sun\Java\Deployment\" -Recurse

The deployment folder is empty even though there are supposed to be more directories and a file in the folder.

I had also used the following command at one point and it did not work

Copy-FileToUserProfiles -Path "$dirFiles\Sun" -Destination "AppData\Roaming" -Recurse

I am testing this on a Windows 11 22H2 VM.

Does anyone have any suggestions to help troubleshoot or resolve this?

Thanks in advance.


What does the PSADT log file say when it processes Copy-FileToUserProfiles ?


Here are the logs for one of the users

[Post-Installation] :: Copying path [D:\DMIS (with JRE 1.8.271 x86)\Files\Sun] to C:\Users\Default\AppData\Roaming\Sun\Java\Deployment: Copy-FileToUserProfiles 17/06/2024 17:23:08 9164 (0x23CC)
[Post-Installation] :: Destination assumed to be a folder which does not exist, creating destination folder [C:\Users\Default\AppData\Roaming\Sun\Java\Deployment]. Copy-File 17/06/2024 17:23:08 9164 (0x23CC)
[Post-Installation] :: Copying file(s) recursively in path [D:\DMIS (with JRE 1.8.271 x86)\Files\Sun] to destination [C:\Users\Default\AppData\Roaming\Sun\Java\Deployment]. Copy-File 17/06/2024 17:23:08 9164 (0x23CC)
[Post-Installation] :: Executing Robocopy command: C:\Windows\System32\Robocopy.exe /NJH /NJS /NS /NC /NP /NDL /FP /IS /IT /IM /XX /MT:4 /R:1 /W:1 /E “D:\DMIS (with JRE 1.8.271 x86)\Files” “C:\Users\Default\AppData\Roaming\Sun\Java\Deployment” “Sun” Copy-File 17/06/2024 17:23:08 9164 (0x23CC)
[Post-Installation] :: [C:\Windows\System32\Robocopy.exe] is a valid fully qualified path, continue. Execute-Process 17/06/2024 17:23:08 9164 (0x23CC)
[Post-Installation] :: Working Directory is [C:\Windows\System32]. Execute-Process 17/06/2024 17:23:08 9164 (0x23CC)
[Post-Installation] :: Executing [C:\Windows\System32\Robocopy.exe /NJH /NJS /NS /NC /NP /NDL /FP /IS /IT /IM /XX /MT:4 /R:1 /W:1 /E “D:\DMIS (with JRE 1.8.271 x86)\Files” “C:\Users\Default\AppData\Roaming\Sun\Java\Deployment” “Sun”]… Execute-Process 17/06/2024 17:23:08 9164 (0x23CC)
[Post-Installation] :: PassThru parameter specified, returning execution results object. Execute-Process 17/06/2024 17:23:09 9164 (0x23CC)
[Post-Installation] :: Execution completed and the exit code [0] is being ignored. Execute-Process 17/06/2024 17:23:09 9164 (0x23CC)
[Post-Installation] :: Robocopy output:
Copy-File 17/06/2024 17:23:09 9164 (0x23CC)
[Post-Installation] :: Robocopy completed. No files were copied. No failure was encountered. No files were mismatched. The files already exist in the destination directory; therefore, the copy operation was skipped. Copy-File 17/06/2024 17:23:09 9164 (0x23CC)

Thanks for the suggestion


I figured out what was happening, I copied and pasted from the command reference section of this site. I thought the variable in use in the example was $dirSupportFiles but it was $dirFiles which means the command was looking in the wrong place for the source files to copy.

Thanks for your time everyone.



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.