?
Solved

Powershell Script  - I want to move Logs from \\server01\Stroage\subfolders to \\server02\stroage\newfolderwithdate\subfolders

Posted on 2014-09-09
3
Medium Priority
?
187 Views
Last Modified: 2014-09-18
I want to move Logs older than 3 moths from \\server01\Stroage\subfolders to \\server02\stroage\newfolderwithdate\subfolders (as from destination) , after copied ,verfied , delete all copied ones.

many thanks
0
Comment
Question by:SAIMSKY ADMIN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 40313073
Try this code and see if it works for you..
#Update the source and destination folder path
$Source = "\\server01\Stroage"
$Dest = "\\server02\stroage"

#Create destination folder if it doesn't exist
$D = "$Dest\Folder$(get-date -f dd-MM-yyyy)"
 If (!(Test-Path $D)) {New-Item $D -ItemType directory -Force}

#Move files older than 3 months
robocopy $Source $D /s /mov /minage:$(((Get-Date) - (get-date).AddMonths(-3)).TotalDays)

#or you can change the parameter value /minage:90 if you are not worried about the exact 3 moths period

Open in new window

0
 
LVL 23

Expert Comment

by:yo_bee
ID: 40313200
You can all try this.
$soruce = "\\netapp01\AdminData\FLH Confidental"
$dest = "\\netapp01\itdata"
$a = Get-ChildItem $soruce\* -recurse  ##-Include Archive*
 ForEach ($x in $a)
    {
        $y=((Get-Date)-$x.lastwritetime).days
        ##Write-Host $x.FullName
        If ($y -gt 90 )
       {Move-Item -Path $x.FullName -Destination $dest}
       
         
    }

Open in new window

0
 

Author Closing Comment

by:SAIMSKY ADMIN
ID: 40329793
thanks
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question