Unix/Linux Go Back    


Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

Powershell Script Help

Windows & DOS: Issues & Discussions


Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 03-30-2012   -   Original Discussion by freedavis
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 13 December 2017, 10:16 AM EST
Location: Saskatchewan
Posts: 22,546
Thanks: 1,159
Thanked 4,286 Times in 3,955 Posts
Moved to the Windows subforum.
Sponsored Links
    #9  
Old Unix and Linux 07-26-2012   -   Original Discussion by freedavis
useerup's Unix or Linux Image
useerup useerup is offline
Registered User
 
Join Date: Jul 2012
Last Activity: 26 July 2012, 4:26 AM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Code:
ls c:\test\*.LOG, f:\test\*.LOG, e:\test\*.LOG | ?{ $_.LastWriteTime -lt (get-date).AddDays(-$keep) } | mv -Dest C:\Logfiles\Archive

Sponsored Links
    #10  
Old Unix and Linux 08-09-2012   -   Original Discussion by freedavis
bdittmar's Unix or Linux Image
bdittmar bdittmar is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 13 December 2017, 6:26 AM EST
Location: Germany
Posts: 89
Thanks: 2
Thanked 9 Times in 9 Posts
On WIN use robocopy

Quote:
Originally Posted by freedavis View Post
Need some help getting this script to work. can someone help. I am trying to create a script that moves log files to another location and only keeps 60 days worth. please see script I started but having issue getting to work..


Code:
$TODAY=GET-DATE
GET-CHILDITEM C:\test\*.LOG | Where { $_.LastWriteTime.AddDays(31) -lt $TODAY } | MOVE-ITEM C:\Logfiles\Archive
GET-CHILDITEM F:\test\*.LOG | Where { $_.LastWriteTime.AddDays(31) -lt $TODAY } | MOVE-ITEM C:\Logfiles\Archive
GET-CHILDITEM E:\test\*.LOG | Where { $_.LastWriteTime.AddDays(31) -lt $TODAY } | MOVE-ITEM C:\Logfiles\Archive

Hello,

microsoft's robocopy will do the trick.

Regards
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with shell script - Calling a script through script Siddheshk Shell Programming and Scripting 0 04-18-2011 06:14 AM
Does PowerSHell have *stat command analogs? Xcislav Windows & DOS: Issues & Discussions 1 03-31-2011 01:08 PM
create a shell script that calls another script and and an awk script magikminox Shell Programming and Scripting 0 06-26-2008 03:50 AM



All times are GMT -4. The time now is 08:57 AM.