Thursday, December 19, 2019

Powershell script to Move folders/files from one location to another

Nice and handy Powershell script to Move folders/files from one location to another. This can be used as archival script. It will be good to add Compression and zip functionality.


Add-Type -assembly 'system.io.compression.filesystem'

$source = "\\sourceServer\Folders\*"
$dest = "\\destinationServer\Archive"

if (Test-Path -path $dest) {
  Write-Host "Move Item"
  Move-Item -Path $source -Destination $dest -force
}

  Write-Host "Completed"