Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

PENDING Powershell script to copy user desktop and document to their hostname folder.

  • Thread starter Thread starter Nitin_ted
  • Start date Start date
  • Replies Replies 3
  • Views Views 8K

Nitin_ted

Well-Known Member
Messages
87
Solutions
1
Reaction score
2
Points
8
Hello everyone, I'm seeking advice on creating a PowerShell or batch script. The script should copy the "Documents" and "Desktop" files from the latest user folder in the "C:\Users" directory to a destination folder. I have already set up folders using hostnames, so I need the script to match the hostname with the corresponding destination folder and copy the files into it. Any guidance on how to accomplish this would be greatly appreciated.
 
 
i tried above link but its not working (not copying the file in order, and some of the folder/file not copy too). Can you suggest what i doing wrong here?

$source = (Get-ChildItem -Path "C:\Users" | where {$_.Name -ne "administrator"}).FullName
$destination = "\\server\ITD_Data\$env:ComputerName"
Copy-Item -Path $source -Destination $destination -Recurse
 
i tried above link but its not working (not copying the file in order, and some of the folder/file not copy too). Can you suggest what i doing wrong here?

$source = (Get-ChildItem -Path "C:\Users" | where {$_.Name -ne "administrator"}).FullName
$destination = "\\server\ITD_Data\$env:ComputerName"
Copy-Item -Path $source -Destination $destination -Recurse
Assuming you are using ConfigMgr to deploy this script. it is to be expected as the UNC will not be accessible by the computer account. You will need to grant permission for this to work.

Also add logging to you script if you want to know what is going on.
 

Forum statistics

Threads
7,197
Messages
28,083
Members
18,355
Latest member
mattjimf

Latest posts

Back
Top