Powershell Script Help

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Powershell Script Help
# 8  
Old 03-30-2012
Moved to the Windows subforum.
# 9  
Old 07-26-2012
Code:
ls c:\test\*.LOG, f:\test\*.LOG, e:\test\*.LOG | ?{ $_.LastWriteTime -lt (get-date).AddDays(-$keep) } | mv -Dest C:\Logfiles\Archive

# 10  
Old 08-09-2012
On WIN use robocopy

Quote:
Originally Posted by freedavis
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
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

powershell script to unix shell script conversion.

Here is a powershell script to use restful API to create ticket in our ticketing tool. Can anyone please convert it to a shell script sothat, I can run it in Unix servers, below is the code: $body = @{ Customer= ''test' Summary= 'test summary' Impact= '4-Minor/Localized' ... (2 Replies)
Discussion started by: pandeybhavesh18
2 Replies

2. UNIX for Advanced & Expert Users

Running Powershell Script from Linux through Cygwin

Hello Experts, I am creating a run time powershell script on Linux machine and copying that powershell script to Windows machine. To connect to windows through "ssh", I am using Cygwin tool. To make the connection password less I copied my public in authorized_keys in windows Administrator... (5 Replies)
Discussion started by: shekhar_4_u
5 Replies

3. Shell Programming and Scripting

Execute powershell script with UNIX

Hi I have a powershell script which is checking whether a windows service is running (as shown below) function FuncCheckService { $ServiceName = 'pgsql-9.2' $arrService = Get-Service -Name $ServiceName if ($arrService.Status -eq 'Running') { Write-Output... (8 Replies)
Discussion started by: simpsa27
8 Replies

4. Shell Programming and Scripting

Powershell script to monitor windows process

Hello Friend, I am not expert in power shell scripting. I nee custom powershell script which check if given process is running on windows machine or not. will use it in nagios to monitor that process. (0 Replies)
Discussion started by: ghpradeep
0 Replies

5. Windows & DOS: Issues & Discussions

Powershell + office 365

Hello ! I am looking for powershell guys. I have lot of office365 users ,and i need add/remove calendar items from powershell. my users have multiple calendars. how can i select calendar ,and how can i add / remove item to selected calendar. PS C:\appl\o365calendar> get-mailboxfolder... (0 Replies)
Discussion started by: zoldkovacs
0 Replies

6. Shell Programming and Scripting

Bash script - cygwin (powershell?) pull from GitHub API Parse JSON

All, Have a weird issue where i need to generate a report from GitHub monthly detailing user accounts and the last time they logged in. I'm using a windows box to do this (work issued) and would like to know if anyone has any experience scripting for GitAPI using windows / cygwin / powershell?... (9 Replies)
Discussion started by: ChocoTaco
9 Replies

7. Windows & DOS: Issues & Discussions

To find a value in atext file using powershell

Hi All, i have a VB script which help me in downloading the text file(mail attachment) to my local drive from outlook.i want to check some values in the text file. for ex A date1 count count miss 2/25/2014 42 42 0 B date2 ... (0 Replies)
Discussion started by: mahesh300182
0 Replies

8. Windows & DOS: Issues & Discussions

Help with PowerShell

I am very not knowledgeable with regards to Windows, and even more so with PowerShell, but I'm hoping someone can help me with what should be a fairly simple script. Remove all local accounts matching a given regular expression It seems like I'd need the following combined... Somehow... ... (0 Replies)
Discussion started by: Vryali
0 Replies
Login or Register to Ask a Question