Jump to content

Recommended Posts

Posted

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!!

Posted

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

Posted (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 by Reverend_Dan

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...