Sponsored Content
Full Discussion: Powershell Script Help
Special Forums Windows & DOS: Issues & Discussions Powershell Script Help Post 302684219 by bdittmar on Thursday 9th of August 2012 09:54:32 AM
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
 

8 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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
Prima::IniFile(3)					User Contributed Perl Documentation					 Prima::IniFile(3)

NAME
Prima::IniFile - support of Windows-like initialization files DESCRIPTION
The module contains a class, that provides mapping of text initialization file to a two-level hash structure. The first level is called sections, which groups the second level hashes, called items. Sections must have unique keys. The items hashes values are arrays of text strings. The methods, operated on these arrays are get_values, set_values, add_values and replace_values. SYNOPSIS
use Prima::IniFile; my $ini = create Prima::IniFile; my $ini = create Prima::IniFile FILENAME; my $ini = create Prima::IniFile FILENAME, default => HASHREF_OR_ARRAYREF; my $ini = create Prima::IniFile file => FILENAME, default => HASHREF_OR_ARRAYREF; my @sections = $ini->sections; my @items = $ini->items(SECTION); my @items = $ini->items(SECTION, 1); my @items = $ini->items(SECTION, all => 1); my $value = $ini-> get_values(SECTION, ITEM); my @vals = $ini-> get_values(SECTION, ITEM); my $nvals = $ini-> nvalues(SECTION, ITEM); $ini-> set_values(SECTION, ITEM, LIST); $ini-> add_values(SECTION, ITEM, LIST); $ini-> replace_values(SECTION, ITEM, LIST); $ini-> write; $ini-> clean; $ini-> read( FILENAME); $ini-> read( FILENAME, default => HASHREF_OR_ARRAYREF); my $sec = $ini->section(SECTION); $sec->{ITEM} = VALUE; my $val = $sec->{ITEM}; delete $sec->{ITEM}; my %everything = %$sec; %$sec = (); for ( keys %$sec) { ... } while ( my ($k,$v) = each %$sec) { ... } METHODS
add_values SECTION, ITEM, @LIST Adds LIST of string values to the ITEM in SECTION. clean Cleans all internal data in the object, including the name of the file. create PROFILE Creates an instance of the class. The PROFILE is treated partly as an array, partly as a hash. If PROFILE consists of a single item, the item is treated as a filename. Otherwise, PROFILE is treated as a hash, where the following keys are allowed: file FILENAME Selects name of file. default %VALUES Selects the initial values for the file, where VALUES is a two-level hash of sections and items. It is passed to read, where it is merged with the file data. get_values SECTION, ITEM Returns array of values for ITEM in SECTION. If called in scalar context, and there is more than one value, the first value in list is returned. items SECTION [ HINTS ] Returns items in SECTION. HINTS parameters is used to tell if a multiple-valued item must be returned as several items of the same name; HINTS can be supplied in the following forms: items( $section, 1 ) items( $section, all => 1); new PROFILE Same as create. nvalues SECTION, ITEM Returns number of values in ITEM in SECTION. read FILENAME, %PROFILE Flushes the old content and opens new file. FILENAME is a text string, PROFILE is a two-level hash of default values for the new file. PROFILE is merged with the data from file, and the latter keep the precedence. Does not return any success values but, warns if any error is occurred. replace_values SECTION, ITEM, @VALUES Removes all values form ITEM in SECTION and assigns it to the new list of VALUES. section SECTION Returns a tied hash for SECTION. All its read and write operations are reflected in the caller object, which allows the following syntax: my $section = $inifile-> section( 'Sample section'); $section-> {Item1} = 'Value1'; which is identical to $inifile-> set_items( 'Sample section', 'Item1', 'Value1'); sections Returns array of section names. set_values SECTION, ITEM, @VALUES Assigns VALUES to ITEM in SECTION. If number of new values are equal or greater than the number of the old, the method is same as replace_values. Otherwise, the values with indices higher than the number of new values are not touched. write Rewrites the file with the object content. The object keeps an internal modification flag under name "{changed}"; in case it is "undef", no actual write is performed. AUTHORS
Anton Berezin, <tobez@plab.ku.dk> Dmitry Karasik <dmitry@karasik.eu.org> perl v5.14.2 2009-02-24 Prima::IniFile(3)
All times are GMT -4. The time now is 08:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy