Ir al contenido principal

Script Powershell para saber un promedio de cantidad de correos y tamaño diario.

# Initialize some variables used for counting and for output
$From = Get-Date "15/07/2014"
$To = $From.AddDays(1)
$TotalOutput = @()

 
[Int64] $intSent = $intRec = 0
[Int64] $intSentSize = $intRecSize = 0
[String] $strEmails = $null
 
 
Do
{
    # Start building the variable that will hold the information for the day
    $obj = new-object PSObject
    $obj | add-member -membertype NoteProperty -name "DayOfWeek" -value $($From.DayOfWeek)  
    $obj | add-member -membertype NoteProperty -name "Date" -value $($From.ToShortDateString())
 
    $intSent = $intRec = 0
    (Get-TransportServer) | Get-MessageTrackingLog -ResultSize Unlimited -Start $From -End $To | ForEach {
        # Sent E-mails
        If ($_.EventId -eq "RECEIVE" -and $_.Source -eq "STOREDRIVER")
        {
            $intSent++
            $intSentSize += $_.TotalBytes
        }
         
        # Received E-mails
        If ($_.EventId -eq "DELIVER")
        {
            $intRec++
            $intRecSize += $_.TotalBytes
        }
    }
 
    $intSentSize = [Math]::Round($intSentSize/1KB, 0)
    $intRecSize = [Math]::Round($intRecSize/1KB, 0)
 
    # Add the numbers to the $strEmails variable and print the result for the day
    $obj | add-member -membertype NoteProperty -name "Sent" -value $intSent
    $obj | add-member -membertype NoteProperty -name "Sent Size (KB)" -value $intSentSize
    $obj | add-member -membertype NoteProperty -name "Received" -value $intRec
    $obj | add-member -membertype NoteProperty -name "Received Size (KB)" -value $intRecSize
    $strEmails += "$intSent,$intSentSize,$intRec,$intRecSize"

    $TotalOutput+=$obj
    $obj=$null
 
    # Increment the From and To by one day
    $From = $From.AddDays(1)
    $To = $From.AddDays(1)
}
#While ($To -lt (Get-Date))
While ($To -lt (Get-Date "17/07/2014"))

$TotalOutput | export-csv -path c:\PromedioCantidadMail.csv -NoTypeInformation

Entradas más populares de este blog

Probando Workplace join en Windows Server 2012 R2

Buen día, La idea del día de hoy es hacer un laboratorio de prueba para probar la característica Workplace join de Windows Server 2012 R2. La función de esta característica es poder realizar Single-Sign-On desde dispositivos IOs y Android para consumir datos y servicios en nuestra red corporativa, dado que estos dispositivos no pueden ser incluidos como objetos en nuestro Active Directory. Para poder realizar este laboratorio vamos a necesitar tener un dominio de Active Directory, también necesitaremos implementar Active Directory Federation Services y Active Directory Certification Services, este ultimo para emitir certificados internamente en nuestra organización. En mi caso ya tengo un laboratorio con un dominio creado y el controlador de dominio correspondiente, también eh implementado el rol de Active Directory Certificate Services para los certificados. El foco principal que quiero abordar aquí son los pasos correspondientes a la implementación de la característica Workpl...

Crear servidor Ansible

Servidor Ansible Comenzamos instalando un sistema operativo CentOS 7 minimal, podemos hacerlo sobre una maquina virtual Hyper-V, Vmware o en la nube. En Centos 7 instalación mínima por defecto no se tiene conexión a la red dado que las interfaces ethernet no vienen habilitadas de forma predeterminada. Ejecutar comando " nmcli d " para un listado rápido de las interfaces de red instaladas en el equipo. Ejecutar el comando " nmtui " para abrir el Network manager Editar las interfaces y configurar en automático IPv4 y marcar la opción "Conectar de forma automática"  para obtener dirección IP desde un servidor DHCP. Ejecutar " Service Network Restart " Instalar el repositorio EPEL para Centos 7 Ejecutar " yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm " Instalar ansible Ejecutar " yum install ansible " Ejecutar " yum install python-pip " Ejecutar " pip inst...

Comandos para instalar prerequisitos Exchange 2010 SP3 en Windows Server 2008 R2 SP1

Import-Module ServerManager Add-WindowsFeature AS-NET-Framework,AS-HTTP-Activation,RSAT-ADDS,RPC-over-HTTP-Proxy,Web-Basic-Auth,Web-Windows-Auth,Web-Digest-Auth,Web-Net-Ext,Web-ASP-Net,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Client-Auth,Web-HTTP-Redirect,Web-HTTP-Tracing,Web-Dyn-Compression,Web-Metabase,Web-WMI,Web-Lgcy-Mgmt-Console