Solved

available space on disk and delete logs

Posted on 2012-03-12
3
384 Views
Last Modified: 2012-06-22
Hi Experts,

I think this is the right place to put the question. I need your help, I am studying powershell but I am having difficult to write the script with powershell. I have not enough skills.

I would need a powershell such as:

- It will be launch from  my workstation or server of my domain providing administrattors credential in other domains to be able to execute command there.
- The goal is to get:
* To get information about differents hard disk units on target server; total space in disk and free space available. (could have c,d,e,...) units. There is not a rule.
* Export that information to excel, creating the file iin the pc where the scrilpt is being launching (source pc in which I am launching the script). The name of the file is the same that the IP adress of the server where we are connecting to get information.
* In a specific folder on the target server check for files which are  contained into a specific folder and are two weeks old, the goal is delete them (are logs files). report the action in a logs indicating amount of deleted files and the size disk.

Please, I need the help of an expert, It is very important for me to be able to finish this task.
0
Comment
Question by:projectja
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
DBAduck - Ben Miller earned 500 total points
ID: 37714679
Since you are studying PowerShell I will help you along the way.

To get the disk space for the the drives on the other machine the command would be like this:

Get-WmiObject -class Win32_Volume -computerName SERVERNAME | Select Name, Capacity, FreeSpace

The deletion of a file that is 2 weeks old, you can use something like this:

foreach($file in (Get-ChildItem \\path\to\directory\on\server)) {
     if(((Get-Date) - $file.LastWriteTime) -ge 14) {
           Remove-File $file
     }
}

That should get you started.
0
 

Author Comment

by:projectja
ID: 37717336
Thank you very much for the reply.

I am going to work in the script, if I have questions I am aboslutaly sure you adn all the experts, will support to me.

Please, let me to work with the scrpt before accept a solution.

See you
0
 

Author Closing Comment

by:projectja
ID: 37732368
It has become the bsae of my scriplt
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question