Showing posts with label Exchange 2010. Show all posts
Showing posts with label Exchange 2010. Show all posts

Tuesday, 15 March 2016

Released: March 2016 Quarterly Exchange Updates



Microsoft released the quarterly updates for Exchange Server are now available on the Microsoft Download Center. Exchange Server 2016 receives its first Cumulative Update, and Exchange Server 2013 Cumulative Update 12 is also released. Exchange Server 2007 and Exchange Server 2010 Update Rollups provide an updated OWA S/MIME control signed with a SHA-2 certificate. More information and highlights of all these releases can be found below. 

Updated OWA S/MIME control

All of the packages released today include an update to the OWA S/MIME control. The control itself has not changed, but has now been signed with a SHA-2 compliant certificate. All of the updates released will install the updated control onto the Exchange Server. Users who have installed the control into their browser will need to re-install this onto devices where the previous version was installed. Installing the control is straight forward and can be done quickly using OWA Options, Exchange Control Panel or Exchange Admin Center depending upon the release of Exchange you are using. 

New distribution package for Exchange Server 2016 updates

With the introduction of Cumulative Updates for Exchange Server 2016, we are making a change to the update package type for this product version. Previous versions of Exchange used self-extracting packages to deliver service packs and cumulative updates. We have heard requests to release these updates as .ISO’s. With the capability to mount .ISO’s directly in Windows Server 2012 and later, we think it makes sense to ship Cumulative Updates as .ISO’s. At this time, we are not planning to do this for Exchange Server 2013 Cumulative Updates but could be persuaded to do so if enough people ask for it. One down side to this approach is that the package is much larger. However, copying a single .ISO vs. the ever growing number of files and folders over the network is much more efficient and faster. We hope you like this change. 

Change to Mailbox Anchoring for Remote PowerShell

We heard your feedback on the changes to load balancing Remote PowerShell introduced into Exchange Server 2013 and 2016. As announced by Ross here, we have reverted this behavior in the Cumulative Updates being released today. 

Additional languages for Outlook on the Web

Exchange Server 2016 Cumulative Update 1 adds support for 17 additional languages in Outlook on the Web. These languages will appear automatically in the language selection drop down after a server is updated to Cumulative Update 1. 

.Net 4.6.1 Support

We know that many of you have been asking about .Net 4.6.1 and Exchange. Rest assured we are working closely with the .Net Framework team to resolve issues preventing us from supporting .Net 4.6.1 with Exchange Server. While we are not there yet, we hope to be very soon. Support for .Net 4.6.1 is planned for future Cumulative Updates for Exchange Server 2013 and 2016. 

Slow installations on Windows Server 2012 R2

For customers who are running Exchange on Windows Server 2012 R2, we want to make certain you are aware of a condition which can substantially increase the amount of time it takes to install Exchange Updates on this OS. Working with the .Net team, we have discovered that systems which have applied Windows Update KB3097966 can take 50% more time to install Exchange. The .Net team is working on a resolution to this and will include a fix in a future product update. In the meantime, customers who have deployed this Windows update can take a one-time action on their server before installing Exchange or a Cumulative Update to bring installation time back to normal. This procedure needs to be done once on every Exchange server running Windows Server 2012 R2. The command to execute is: 
“%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe update”
Errors and warnings encountered running this command can be safely ignored provided the final exit status code of 0 is reported in the output. 

Support for Standalone Hybrid Configuration Wizard in Exchange Server 2010

Customers using Exchange Server 2010 in Hybrid mode with Office 365 will notice a new link in the EMC to use the Updated Standalone Hybrid Configuration Wizard. We encourage all customers to use this updated version of the Hybrid Configuration Wizard. 

Release Details

KB articles which contain greater depth on what each release includes are available as follows: 

Thursday, 17 December 2015

What is Mailbox Anchoring

Mailbox Anchoring

In mailbox anchoring, CAS locates where the mailbox resides by querying Active Directory for the user's mailbox GUID. As soon as we obtain the GUID, HTTP Proxy refers to Active Manager to locate the database containing the user's mailbox. Once CAS knows where the user's mailbox is located, the protocol request is then proxied to the appropriate mailbox server. If that server goes down and the database is a part of a DAG, the Client Access Proxy will proxy the session to the new active mailbox server for the corresponding database. This process is utilized currently for most client protocols, such as OWA, ECP, and EWS with the exception of Remote PowerShell.

This is great for the client but what about the Exchange Management Shell (EMS)? In Exchange 2013 RTM through CU10 and Exchange 2016 (RTM), we do not use the mailbox anchoring logic to proxy the PowerShell session we just connect to the local server or proxy to another available server in the Exchange Organization. This means if I log into an Exchange 2013 Server I cannot manage any new cmdlets that became available in Exchange 2016. For that I would have to logon directly to an Exchange 2016 Server.
EMS changes
Starting with Exchange Server 2013 CU11 and Exchange Server 2016 CU1, the Exchange Management Shell (EMS) session will also be using mailbox anchoring. If the aforementioned environment has all servers upgraded to Exchange 2013 CU11 and Exchange 2016 CU1 the behavior of Exchange Management Shell changes. Now when a user logs on to the Exchange Server and open up EMS, the session will be proxied to the server where the user’s mailbox is located. If the user does not have a mailbox, we will utilize the arbitration mailboxes for the mailbox anchoring logic. Wherever the arbitration mailbox is mounted is where the EMS session will be proxied.

December 2015 Quarterly Exchange Updates



The Exchange team is announcing the availability of our latest quarterly update for Exchange Server 2013 as well as updates for Exchange Server 2010 Service Pack 3 and Exchange Server 2007 Service Pack 3.

Cumulative Update 11 for Exchange Server 2013

A complete list of customer reported issues resolved can be found in Knowledge Base Article KB3099522. Customers running any previous release of Exchange Server 2013 can move directly to Cumulative Update 11. Customers deploying Exchange Server 2013 for the first time may skip previous releases and start their deployment with Cumulative Update 11 directly.

Cumulative Update 11 does not include updates to Active Directory Schema, but may add additional RBAC definitions to your existing configuration. PrepareAD should be executed prior to upgrading any servers to CU11. PrepareAD will run automatically during the first server upgrade if Setup detects this is required and the logged on user has sufficient permission.

Update Rollup 12 for Exchange Server 2010 Service Pack 3 (KB3096066). The Exchange Server 2010 update includes a DST update as well as a collection of important fixes. Update Rollup 18 for Exchange Server 2007 Service Pack 3 (KB3078672) is also being released. Update Rollup 18 is primarily a DST fix with an additional opportunistic fix. 
We would like to call attention to two particularly important changes included in these updates: 
  • Cumulative Update 11 and Update Rollup 12 each contain a time zone calculation fix to resolve the issue reported in KB3048372 – Exchange Calendar Items are shifted incorrectly when some Windows DST updates are applied. Customers in impacted time zones are encouraged to deploy these updates to address the issue identified after the release of the OS time zone changes in KB3039024. 
  • Cumulative Update 11 also includes a change in behavior when deploying/administering Exchange Server 2013 in a co-existent manner with Exchange Server 2010 or 2016. These changes are outlined in the following blog article: Exchange Management Shell and Mailbox Anchoring.


Friday, 28 August 2015

Script to generate email statistics report


About the script

This script is written in a simple logic. This will give you very basic statistics about an email messages which are sent and received by your organization. We can enable email function, if you want to get the report as an email format or it will just generate an html file and store it in a location from where you are running this script. You have to give start and end date to capture the statistics.

Script will capture the below parameters

1. Total email sent/received
2. Total email size sent/received
3. Top sender/receiver
4. Top sized email sent/received by your exchange server

Future Enhancements

1. Will add more parameters for the statistics
2. Will add the graph/chart

Script Block

#Script Begins

$StartDate = Read-Host "Enter Start Date in MM/DD/YYYY Format"
$EndDate = Read-Host "Enter End Date in MM/DD/YYYY Format"

# Inputs for Email

$Subject = "Email Statistics Report Generated on" + $(Get-Date).toshortdatestring() + " at " + $(Get-Date).ToshorttimeString()
$FromAddress = "admin@lyncit.net"
$ToAddress = "john@lyncit.net"
$Relay = "ex01.lyncit.net"
$SMTPClient = New-Object System.Net.Mail.smtpClient
$MailMessage = New-Object System.Net.Mail.MailMessage

# Mail Function

$Mail = "True"

$body = $null
$body += '<style>'
$body += '<!-- '
$body += 'body { font: Calibri } '
$body += 'table { font: 11pt Calibri; border: 1px} '
$body += 'td { border: 1px ridge white; padding-left: 1px; padding-right: 1px } '
$body += 'p.header { font: 11pt Verdana; color: DarkBlue }'
$body += 'p.normal { font: 8pt Calibri; color: CadetBlue }'
$body += '-->'
$body += '</style>'
$body += '</head>'
$body += '<body>'
#$body += "<p class=`"header`" align='center'><strong>Email Statistics Report Generated on: " + $(Get-Date).toshortdatestring() + " at " + $(Get-Date).ToshorttimeString()
$body += "<p class=`"header`" align='center'><strong>Email Statistics Report between " + $StartDate + " and " + $EndDate


$msgsent = Get-Exchangeserver | where {$_.isHubTransportServer -eq $true -or $_.isMailboxServer -eq $true} | Get-Messagetrackinglog -start $StartDate -end $EndDate -EventID "RECEIVE" -resultsize unlimited | Select-Object Timestamp,Clienthostname,eventid,source,sender,@{Name="Recipients";Expression={$_.recipients}},Recipientcount,serverhostname,totalbytes,messagesubject

$msgreceive = Get-Exchangeserver | where {$_.isHubTransportServer -eq $true -or $_.isMailboxServer -eq $true} | Get-Messagetrackinglog -start $StartDate -end $EndDate -EventID "DELIVER" -resultsize unlimited | Select-Object Recipients,totalbytes

$msg1 = $msgsent | Measure-Object totalbytes -Maximum -minimum -average -sum
$msgsentcount = $msgsent.count
$msgsentsize = $msg1.sum / (1024 * 1024)
$size = "{0:N2}" -f $msgsentsize + "MB"

$bigsent = $msg1.maximum / (1024 * 1024)
$bigsentmb = "{0:N2}" -f $bigsent + "MB"


$msg2 = $msgreceive | Measure-Object totalbytes -Maximum -minimum -average -sum
$msgrcount = $msgreceive.count
$msgrsize = $msg2.sum / (1024 * 1024)
$rsize = "{0:N2}" -f $msgrsize + "MB"

$bigr = $msg2.maximum / (1024 * 1024)
$bigrmb = "{0:N2}" -f $bigr + "MB"

Write-Host $msgsentcount
Write-Host $size
if ($msgsent -ne $null)
{
        #Table Header
        $body += '<table width=80% align=center>'
        $body += '<td colspan=2 align=center style="background-color: #DCDCDC" border: 1 ; ><strong><font color= Black>' + "SENT EMAILS STATISTICS"  + '</font></strong></td></tr>'
        $body += '<tr><td align="Center" style="background-color: #736F6E" width="13%" border: 1 Groove white;><p class="table" style="color:    white"><b>Parameters</b></p></td>'
        $body += '<td align="Center" style="background-color: #736F6E" width="10%" border: 1 Groove white;><p class="table" style="color:    white"><b>Value</b></p></td>'
$body += '<tr><td align="Center" border: 1 Groove white;>' + "Total Emails Sent" + "</td>"
        $body += '<td align="Center" border: 1 Groove white;>' + $msgsentcount + "</td></tr>"
$body += '<tr><td align="Center" border: 1 Groove white; >' + "Total Sent Emails Size" + "</td>"
$body += '<td align="Center" border: 1 Groove white;>' + $size + "</td></tr>"
$body += '<tr><td align="Center" border: 1 Groove white; >' + "Top sent Email size" + "</td>"
$body += '<td align="Center" border: 1 Groove white;>' + $bigsentmb + "</td></tr>"


$senders = $msgsent | Group-Object Sender | Sort-Object Count -Descending | Select-Object -first "10"


$body += '<td colspan=2 align=center style="background-color: #DCDCDC" border: 1 ; ><strong><font color= Black>' + "Top 10 Senders"  + '</font></strong></td></tr>'
$body += '<tr><td align="Center" style="background-color: #736F6E" width="13%" border: 1 Groove white;><p class="table" style="color:    white"><b>Name</b></p></td>'
        $body += '<td align="Center" style="background-color: #736F6E" width="10%" border: 1 Groove white;><p class="table" style="color:    white"><b>Sent Message Count</b></p></td>'
foreach ($SenderEntry in $senders)
{
 
$name = $senderentry.name
$count = $senderentry.count


$body += '<tr><td align="Center" border: 1 Groove white;>' + $name + "</td>"
            $body += '<td align="Center" border: 1 Groove white; >' + $count + "</td></tr>"

}

$body += '<td colspan=2 align=center style="background-color: #DCDCDC" border: 1 ; ><strong><font color= Black>' + "RECEIVED EMAILS STATISTICS"  + '</font></strong></td></tr>'
        $body += '<tr><td align="Center" style="background-color: #736F6E" width="13%" border: 1 Groove white;><p class="table" style="color:    white"><b>Parameters</b></p></td>'
        $body += '<td align="Center" style="background-color: #736F6E" width="10%" border: 1 Groove white;><p class="table" style="color:    white"><b>Value</b></p></td>'
$body += '<tr><td align="Center" border: 1 Groove white;>' + "Total Emails Received" + "</td>"
        $body += '<td align="Center" border: 1 Groove white;>' + $msgrcount + "</td></tr>"
$body += '<tr><td align="Center" border: 1 Groove white; >' + "Total Received Emails Size" + "</td>"
$body += '<td align="Center" border: 1 Groove white;>' + $rsize + "</td></tr>"
$body += '<tr><td align="Center" border: 1 Groove white; >' + "Top Receive Email size" + "</td>"
$body += '<td align="Center" border: 1 Groove white;>' + $bigrmb + "</td></tr>"


$Userarray = @()
$Measure_Receivers = Measure-Command `
{
 
$msgReceive | foreach {$_.Recipients -split(" ") | foreach {$Userarray += $_} | Out-Null}
    $Userarray = $Userarray | group
    $Receivers = $Userarray | Sort-Object Count -Descending | Select-Object -first "10"
}
$TopRec_file = ""
$TopReceiver = ""
$TopRec = "`n`n"

$body += '<td colspan=2 align=center style="background-color: #DCDCDC" border: 1 ; ><strong><font color= Black>' + "Top 10 Receivers"  + '</font></strong></td></tr>'
$body += '<tr><td align="Center" style="background-color: #736F6E" width="13%" border: 1 Groove white;><p class="table" style="color:    white"><b>Name</b></p></td>'
$body += '<td align="Center" style="background-color: #736F6E" width="10%" border: 1 Groove white;><p class="table" style="color:    white"><b>Email Count</b></p></td>'

foreach ($User in $Receivers)
{
 
$rname = $user.name
$rcount = $user.count

$body += '<tr><td align="Center" border: 1 Groove white;>' + $rname + "</td>"
            $body += '<td align="Center" border: 1 Groove white; >' + $rcount + "</td>"

}
}
             
$body += '</table><br>'



if ($Mail -eq "True")
{
$body += "Report Completed"
$body += '</p></body></html>'

##############################################################
$MailMessage.Subject = " $Subject
$MailMessage.Body = " $Body
$MailMessage.sender = " $FromAddress
$MailMessage.From = " $FromAddress
$MailMessage.To.add(" $ToAddress)
#$MailMessage.CC.add("$CCAddress")
#$MailMessage.CC.add("$CCAddress2")
$MailMessage.IsBodyHTML = $True
$smtpclient.host = " $Relay
$smtpclient.send($MailMessage)
##############################################################
}
else
{
$d = Get-Date
$name = 'Email_Statistics'
$name += $d.year.tostring()
$name += $d.month.tostring()
$name += $d.day.tostring()
$name += '.html'
Set-Content $name -value $body
}

#Script Ends

Sample HTML output



Sample Email output


Tuesday, 26 May 2015

Exchange 2010/2013 DAG Status validation script

This script will validate the mailbox database status, content index status, copy queue length and replay queue length of the databases from the DAG. It will trigger an email notification to administrator if any of the below condition is true,

1. Database is not mounted on the preferred server
2. Database status is not mounted
3. Database status is not healthy
4. Copy queue length is more than the threshold value
5. Reply queue length is more than the threshold value
6. Content index state is not healthy

We can use this script to validate both Exchange 2010 and 2013 DAG.

We have to schedule a task to run this script. I suggest to schedule this to run every 30 mins and it will trigger an email ONLY when the condition is true. In this way we can avoid spamming administrator mailbox.

Script Block

#######################Beginning of the Script#########################

##########################################################################
#      Check DAG Status and send email                                   # 
#                                                                        # 
# If you want to send the report as an email, please give $Mail = "True" #
##########################################################################

# Inputs for Email 

$Subject = "DAG Status Report" 
$FromAddress = "DAGStatusReport@testlab.com" 
$ToAddress = "admin@testlab.com" 
$Relay = "SMTP relay server FQDN" 
$SMTPClient = New-Object System.Net.Mail.smtpClient 
$MailMessage = New-Object System.Net.Mail.MailMessage 
$Mail = "False"

# Threshold

$CQL = 50
$RQL = 100


#Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin
Set-ADServerSettings -ViewEntireForest $True
$body = $null
$body += '<style>'
$body += '<!-- '
$body += 'body { font: Calibri } '
$body += 'table { font: 11pt Calibri; border: 1px} '
$body += 'td { border: 1px ridge white; padding-left: 1px; padding-right: 1px } '
$body += 'p.header { font: 11pt Verdana; color: DarkBlue }'
$body += 'p.normal { font: 8pt Calibri; color: CadetBlue }'
$body += '-->'
$body += '</style>'
$body += '</head>'
$body += '<body>'
$body += "<p class=`"header`" align='center'><strong>DAG Status Report: " + $(get-date).toshortdatestring() + " @ " + $(get-date).ToshorttimeString() + " [IST]"


$ExchServerName = Get-MailboxServer | ?{$_.Databaseavailabilitygroup} | sort name | %{ 
$ExchServerName = $_.name
write-host "Processing" $_.name
$ccs = $null
$CCS = Get-MailboxDatabaseCopyStatus -Server $ExchServerName  | Where {  ($_.Status -ne "Mounted") -and ($_.Status -ne "Healthy") -or ($_.ContentIndexState -ne "Healthy") -or ($_.replayqueuelength -gt $RQL) -or ($_.CopyQueueLength -gt $CQL) -or (( $_.Status -eq "Mounted") -and ((get-mailboxdatabase $_.databasename).activationpreference[0].key.name -ne $_.activedatabasecopy )) } 


if ($CCS -ne $null)
{
        #Table Header

        $body += '<table width=80% align=center>'
        $body += '<td colspan=6 align=center style="background-color: #DCDCDC" border: 1 ; ><strong><font color= Black>' + ($exchservername).toupper()  + '</font></strong></td></tr>'
        $body += '<tr><td align="Center" style="background-color: #736F6E" width="13%" border: 1 Groove white;><p class="table" style="color:    white"><b>Database</b></p></td>'
        $body += '<td align="Center" style="background-color: #736F6E" width="10%" border: 1 Groove white;><p class="table" style="color:    white"><b>ActiveServer</b></p></td>'
        $body += '<td align="Center" style="background-color: #736F6E" width="12%" border: 1 Groove white;><p class="table" style="color:    white"><b>Status</b></p></td>'
        $body += '<td align="Center" style="background-color: #736F6E" width="7%" border: 1 Groove white;><p class="table" style="color:    white"><b>Copy QL</b></p></td>'
        $body += '<td align="Center" style="background-color: #736F6E" width="8%" border: 1 Groove white;><p class="table" style="color:    white"><b>Replay QL</b></p></td>'
        $body += '<td align="Center" style="background-color: #736F6E" width="10%" border: 1 Groove white;><p class="table" style="color:    white"><b>Content Index </b></p></td></tr>'

        $ccs | foreach {
      
            
            $body += '<tr><td align="Center" border: 1 Groove white;>' + $_.Databasename + "</td>"
            $body += '<td align="Center" border: 1 Groove white; bgcolor=#FEEC80 >' + $_.activedatabasecopy.toupper() + "</td>"
            if (($_.Status -eq "Healthy") -or ($_.Status -eq "Mounted"))
            {
                $body += '<td align="Center" border: 1 Groove white;>' + $_.Status + "</td>"}
            Else 
            {
                $body += '<td align="Center" border: 1 Groove white; bgcolor=#FEEC80 >' + $_.Status + "</td>" 
            }
            if ($_.CopyQueueLength -ge $CQL) 
            {
                $body += '<td align="Center" border: 1 Groove white; bgcolor=#FEEC80>' + $_.CopyQueueLength + "</td>" 
            }
            Else 
            {
                $body += '<td align="Center" border: 1 Groove white;>' + $_.CopyQueueLength + "</td>" 
            }
            if ($_.ReplayQueueLength -ge $RQL) 
            {
                $body += '<td align="Center" border: 1 Groove white; bgcolor=#FEEC80>' + $_.ReplayQueueLength  + "</td>" 
            }
            Else 
            { 
                $body += '<td align="Center" border: 1 Groove white;>' + $_.ReplayQueueLength  + "</td>" 
            }
                
            if ($_.ContentIndexState -eq "Healthy")
            {
                $body += '<td align="Center" border: 1 Groove white;>' + $_.ContentIndexState + "</td></tr>"
            }
            Else 
            {
                $body += '<td align="Center" border: 1 Groove white; bgcolor=#FEEC80 >' + $_.ContentIndexState + "</td></tr>" 
            }
            
        }
        
                $body += '</table><br>'
               
}
}


if ($Mail -eq "True")
{
    $body += "Report Completed"
    ##############################################################################
    $MailMessage.Subject = "$Subject"
    $MailMessage.Body = $body
    $MailMessage.sender = "$FromAddress"
    $MailMessage.From = "$FromAddress"
    $MailMessage.To.add("$ToAddress")
    #$MailMessage.CC.add("$CCAddress")
    #$MailMessage.CC.add("$CCAddress2")
    $MailMessage.Priority = [System.Net.Mail.MailPriority]::High
    $MailMessage.IsBodyHTML = $True
    $smtpclient.host = "$Relay"
    $smtpclient.send($MailMessage)
    #############################################################################
}
else
{
    $Date = get-date
    $FileName = 'DAG_Status_Report'
    $FileName += $Date.year.tostring()
    $FileName += $Date.month.tostring()
    $FileName += $Date.day.tostring()
    $FileName += '.html'
    $body += "Report Completed"    
    set-content $FileName -value $body

}

#######################End of the Script##############################

Sample HTML Output


Sample Email




Monday, 30 March 2015

Basic Script to Generate Disk Space Report from Windows Servers

Nowadays we have many equipped tools to monitor the servers and alert administrators in case of any issues in the servers or applications. These tools normally notify the issues to administrators through email or tickets based on the configuration. To avoid unwanted tickets or emails, most of the administrators would set the thresholds to maximum and that may lead to an outage sometimes. To overcome this, administrators will have a practice to pull (or Automate) an organization health report in daily basis.

This simple PowerShell script helps administrators to pull a disk space report from all their servers and sends email in HTML format. We can set threshold to some better value like 20% and will have some time to troubleshoot in case of an issues. This will not create any spam into your mailbox because we are going to schedule a task to run also we have an option to disable email function and have only the HTML file created.

 Script Block

# Beginning of the Script

###############################################################################################
#
# Generate Disk Space Report and send email.
# If you dont want the email function, then it will just generate a html file
# Script will give you a warnings based on the threshold set.
# We can use this script to pull a Disk Space report for all servers.
# We need to give server names as an input file. This is no required for Exchange Servers.
# How to Run the script
# 1. Create Input list with server names and save the file as "Servers.txt"
# 2. If you want to send the report as email, Give $Mail = "True" else give $Mail = "False"
# 3. Move PS1 and input file into same directory and run the script
# Date: 03/26/2015
# Not added any error checking into this script yet.
#
###############################################################################################

# Input

#$Servers = Get-ExchangeServer | sort name | %{$_.name}
$Servers = Get-Content C:\Temp\servers.txt
$Mail = "True"

# Threshold

$percentWarning = 20;
$percentCritcal = 10;
$all = 0;

# Inputs for Email

$Subject = "Disk Space Report"
$FromAddress = "DiskSpaceReport@testlab.com"
$ToAddress = "admin@testlab.com"
$Relay = "SMTP relay server FQDN"
$SMTPClient = New-Object System.Net.Mail.smtpClient
$MailMessage = New-Object System.Net.Mail.MailMessage

#############################################################################

#Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin
#$AdminSessionADSettings.ViewEntireForest = $true

$MailSend = $null
$body = $null
$body += '<!--mce:0-->'
$body += '</head>'
$body += '<body>'
$body += "<p class=`"header`" align='center'><strong>Disk Space Report : " + $(get-date).toshortdatestring() + " @ " + $(get-date).ToshorttimeString()

foreach($Server in $Servers)
{
    $Disks = Get-WmiObject -ComputerName $Server -Class Win32_Volume -Filter "FileSystem = 'NTFS'" |Sort Driveletter,Capacity | Select DriveLetter,Name,Caption,Label,Capacity,FreeSpace,FileSystem,SystemName
    $Server = $Server.toupper()
    $Serverprint = "Yes"

    foreach($Disk in $Disks)
    {
        $Label = $Disk.Label
        $Name = $Disk.Name
        [float]$Size = $Disk.Capacity;
        [float]$Freespace = $Disk.FreeSpace;
        $PercentFree = [Math]::Round(($Freespace / $Size) * 100, 2);
        $SizeGB = [Math]::Round($Size / 1073741824, 2);
        $FreeSpaceGB = [Math]::Round($Freespace / 1073741824, 2);
        $UsedSpaceGB = [Math]::Round($SizeGB ñ $FreeSpaceGB, 2);
        $DriveLetter = $Disk.Driveletter
        If (($PercentFree -ge $all))
        {
            while ($Serverprint -eq "Yes")
            {
                #Table Header

                $body += '<table width=80% align=center>'
                $body += '<td colspan=7 align=center style="background-color: #DCDCDC" border: 1 ; ><strong><font color= Black>' + $Server.toupper()  + '</font></strong></td></tr>'

                #column Header

                $body += '<tr><td align="Center" style="background-color: #585858" width="13%" border: 1 Groove white;><p class="table" style="color:    white"><b>Drive</b></p></td>'
                $body += '<td align="Center" style="background-color: #585858" width="14%" border: 1 Groove white;><p class="table" style="color:    white"><b>Drive Label</b></p></td>'
                $body += '<td align="Center" style="background-color: #585858" width="16%" border: 1 Groove white;><p class="table" style="color:    white"><b>Total Capacity (GB)</b></p></td>'
                $body += '<td align="Center" style="background-color: #585858" width="16%" border: 1 Groove white;><p class="table" style="color:    white"><b>Used Capacity (GB)</b></p></td>'
                $body += '<td align="Center" style="background-color: #585858" width="14%" border: 1 Groove white;><p class="table" style="color:    white"><b>Free Space (GB)</b></p></td>'
                $body += '<td align="Center" style="background-color: #585858" width="14%" border: 1 Groove white;><p class="table" style="color:    white"><b>Free Space %</b></p></td>'
                $body += '<td align="Center" style="background-color: #585858" width="13%" border: 1 Groove white;><p class="table" style="color:    white"><b>Status</b></p></td></tr>'
                $Serverprint = "No"
            }      
            If ($DriveLetter -eq $null)
            {
                $SplitDl = $Name.split("\")
                $DriveLetter = $SplitDl[0]
            }  
                $body += '<tr><td align="Center" border: 1 Groove white;>' + $DriveLetter + "</td>"
                $body += '<td align="Center" border: 1 Groove white;>' + $Label + "</td>"
                $body += '<td align="Center" border: 1 Groove white;>' + $SizeGB + "</td>"
                $body += '<td align="Center" border: 1 Groove white;>' + $usedSpaceGB + "</td>"
                $body += '<td align="Center" border: 1 Groove white;>' + $freeSpaceGB + "</td>"
                $body += '<td align="Center" border: 1 Groove white;>' + $percentFree + "</td>"
            If ($percentFree -le $percentCritcal )
            {
                $body += '<td align="Center" border: 1 Groove white; bgcolor="FF6347">' + "Critical" + "</td></tr>"
            }
            elseif (($percentFree -le $percentWarning ) -and ($percentFree -ge $percentCritcal ))
            {
                $body += '<td align="Center" border: 1 Groove white; bgcolor="FFCC66">' + "Warning" + "</td></tr>"
            }
            else
            {
                $body += '<td align="Center" border: 1 Groove white; bgcolor="A3E6AE">' + "Ok" + "</td></tr>"
            }
       
        }

    }
    $body += '</table><br/>'  
}
if ($Mail -eq "True")
{
    $body += "Report Completed"
    ##############################################################################
    $MailMessage.Subject = "$Subject"
    $MailMessage.Body = $body
    $MailMessage.sender = "$FromAddress"
    $MailMessage.From = "$FromAddress"
    $MailMessage.To.add("$ToAddress")
    #$MailMessage.CC.add("$CCAddress")
    #$MailMessage.CC.add("$CCAddress2")
    $MailMessage.Priority = [System.Net.Mail.MailPriority]::High
    $MailMessage.IsBodyHTML = $True
    $smtpclient.host = "$Relay"
    $smtpclient.send($MailMessage)
    #############################################################################
}
else
{
    $Date = get-date
    $FileName = 'Disk_Space_Info'
    $FileName += $Date.year.tostring()
    $FileName += $Date.month.tostring()
    $FileName += $Date.day.tostring()
    $FileName += '.html'
    $body += "Report Completed"   
    set-content $FileName -value $body

}


# End of the Script

Sample Output

Permanently Clear Previous Mailbox Info for EXO Exchange GUID sync issues

Microsoft is introducing a new parameter that can be called by using the Set-User cmdlet in Exchange Online PowerShell. The new para...