Scifigirl Posted October 2, 2019 Posted October 2, 2019 Morning all, I have been asked to copy a set of files from our admin share to a whole school share on a daily basis. My script worked fine for the first few days but is now copying files to the outside of the folder structure. i.e. taking file a from inside folder a and copying it to the root of the folder. can someone please give me a clue as to what in my script is wrong? Copy-Item -Path "\\server\share\rootfolder\foldera\*" -Destination "\\server\share2\rootfolder" -Recurse -Force Thanks in advance!!
CHiLL Posted October 2, 2019 Posted October 2, 2019 I'm not an great at Powershell, but try addding a backslash at the end of the destination path. Copy-Item -Path "\\server\share\rootfolder\foldera\*" -Destination "\\server\share2\rootfolder\" -Recurse -Force
Reverend_Dan Posted October 2, 2019 Posted October 2, 2019 (edited) Can also take the * out, I do something similar with copying folder structures over to the pupil accounts. $locationOfFiles="\\SERVER\SHARE\FOLDERA\" $destinationFolder = "\\SERVER\SHARE2\FOLDERB\" If (Test-Path $destinationFolder) { Copy-Item $locationOfFiles $destinationFolder -Recurse -Force } else { write-host "Cant find destination folder" } edited for structure Edited October 2, 2019 by Reverend_Dan
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now