Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How activate circular logging with coonditions?

$
0
0

Hi Guys,

I would like to do a script in PowerShell:

> That activate circular logging on a exchange bank when the partitions is below of 5 Gb and disable it after 10 minutes.
And send a mail with the hour when the space was below and space state after activate circular logging.

>If the space is up to 5 Gb, the script will finish.

I started my script , but i am not good enough to finish it.

Thank you so much for your help!

This is my PowerShell:

Set objNet = WScript.CreateObject( "WScript.Network" )
 
Const CONVERSION_FACTOR = 1048576
 
strFilename = "c:\scripts\servers.txt"
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
Set objTextStream = objFSO.OpenTextFile(strFilename, 1)
 
Do Until objTextStream.AtEndOfStream
 
    strComputer = objTextStream.ReadLine
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
    FreeMegaBytes = objLogicalDisk.Freespace / CONVERSION_FACTOR
 
    If FreeMegaBytes < 5000 Then
        Wscript.Echo strComputer & " X is below 5GB.  Only " & Int(FreeMegaBytes) & _
            "Warning"
    End


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>