Powershell file copy example. Copy-Item code snippet

Posted on

Probably the first scheduled task you want to do is to periodically copy files from one location to another.
Here the small snippet how to do it in powershell:

   1: # defining log destination
   2: $dest ="C:\somedirectory" 
   4: #Creating destination directory
   5: New-Item $dest -type directory -force 
   7: #File to copy
   8: $iis ="D:\logs\iislog.log"
  10: #Performing copy operation
  11: Copy-Item $iis $dest