powershell - How to use the Copy-Item cmdlet correctly? -


i building small script should copy .zip files special folder called f:\tempzip.

i tried copy-item cmdlet, didn't manage it. script should copy files folder (recursively) ".zip".

this part of script talking about:

get-childitem f:\work\xxx\xxx\xxx -recurse | {$_.extension -eq ".zip"} |  copy-item f:\tempzip 

what have add?

when piping items copy-item need tell "f:\tempzip" destination path.

| copy-item -destination f:\tempzip 

you can cutout piping where operator using get-childitem's parameter -filter.

get-childitem "c:\imscript" -recurse -filter "*.zip" | copy-item -destination "f:\tempzip" 

edit: removal of unnecessary foreach loop , updated explanation.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -