[chef] Re: Powershell query


Chronological Thread 
  • From: Matthew Moretti < >
  • To: " " < >
  • Subject: [chef] Re: Powershell query
  • Date: Tue, 28 Jul 2015 09:19:34 -0400

Scheduled tasks are certainly the direction you want to go. The Windows cookbook has the windows_task resource. Underneath the hood it relies on schtask, but abstracts a good deal of the complexity away under a resource. Hope that gets you pointed in the right direction.

Matt Moretti


On Tue, Jul 28, 2015 at 4:27 AM, ANGELA EBIRIM < " target="_blank"> > wrote:
Hi everyone,

I'm hoping someone could help me with this as I'm stuck!

I have a powershell command: powershell.exe Get-ChildItem C:\Users\ae\AppData\Local\Temp\3\logstash | Where-Object {_.LastwriteTime -lt (Get-Date).addhours(-12} | Remove-Item -Recurse -Force

which essentially deletes folders within the logstash directory that are older than 12 hours. This needs to be done at a certain time each day.

This command will be included in a Chef recipe and deployed to a Windows Server box.

I'm having difficulty getting this to run at a certain time and was wondering if anyone knew of a way to do this. I've been using the SCHTASKS windows function but this works on a command line but not within a script.

Is anyone aware of a Chef resource that could do this?

Many thanks
 
Sent from iCloud




Archive powered by MHonArc 2.6.16.

§