boards.ie

Go Back   boards.ie > Tech > Computers & Technology > Computers & Technology

Notices

Reply
 
Thread Tools Search this Thread Display Modes
Old 04-11-2009, 10:14   #1
uch
Registered User
 
uch's Avatar
 
Join Date: Oct 2002
Location: Tír na nÓg
Posts: 760
Send a message via AIM to uch Send a message via Yahoo to uch
Remote delete synthax

Does anybody know the synthax for a script to remotely delete files on a network share based on the age/date attribute of the files ?
__________________
Cad a tharla le mo Síniú
uch is offline   Reply With Quote
Advertisement

To remove these adverts, please create an account, or log in! You must have an account to post anyway :-)
Old 04-11-2009, 10:30   #2
Khannie
Moderator
 
Khannie's Avatar
 
Join Date: May 2004
Location: 53° 34'N, 6° 6'W
Posts: 10,501
You'll need to clarify a bit. Are you accessing the server through ssh? (e.g. putty) and do you know what kind of OS it's running? Usually a network server will be running linux or solaris, that kind of thing. In which case you can use the "find" command to remove files based on their age.
__________________
Half Centaur!

Bridgestone Muay Thai
Khannie is offline   Reply With Quote
Old 04-11-2009, 10:34   #3
uch
Registered User
 
uch's Avatar
 
Join Date: Oct 2002
Location: Tír na nÓg
Posts: 760
Send a message via AIM to uch Send a message via Yahoo to uch
It's just a network share on a NAS, it's shared as a UNC path, the files are SQL backupsthat are shipped to the share, I can setup a maintenence plan to delete them off the local Server(Windows 2003) but SQL Wont delete remote files for me, so I wanted to setup a batch file that could be called by a scheduled task to delete files older than 8 weeks, as I don't want the NAS share to fill up.
__________________
Cad a tharla le mo Síniú
uch is offline   Reply With Quote
Old 04-11-2009, 10:44   #4
Khannie
Moderator
 
Khannie's Avatar
 
Join Date: May 2004
Location: 53° 34'N, 6° 6'W
Posts: 10,501
Ah, gotchta. So you have the share mounted as a drive on your windows machine and you want to write a .bat file to find files older than 8 weeks and remove them.

This looks like it should do the trick for you. I'm not really a .bat man myself so there might be an easier way.

This is the key part:
Code:
Get-ChildItem C:\Test | Select-Object Name, @{Name="Age";Expression={ (((Get-Date) - $_.CreationTime).Days) }} |
Sort-Object Age
There's probably a way of altering that expression for Select-Object to get ones with a date that's > 56 days or whatever.
__________________
Half Centaur!

Bridgestone Muay Thai
Khannie is offline   Reply With Quote
Reply
  boards.ie > Tech > Computers & Technology > Computers & Technology Top

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 19:24.


© boards.ie Ltd. (Ireland) - Hosted by Digiweb Hosting. Message Boards and Forums Directory