![]() |
|
|
#1 |
|
Registered User
![]() |
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ú |
|
|
|
|
Advertisement
|
|
To remove these adverts, please create an account, or log in! You must have an account to post anyway :-) |
|
|
#2 |
|
Moderator
![]() 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.
|
|
|
|
|
|
#3 |
|
Registered User
![]() |
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ú |
|
|
|
|
|
#4 |
|
Moderator
![]() 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
|
|
|
|
![]() |
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|