Powershell – Get the First and Last Day of the Month

You could do this in different ways with powershell. But the whole idea is to keep it simple

$CURRENTDATE=GET-DATE -Format "MM/dd/yyyy"


Send-MailMessage – Send Mail with multiple attachments

Powershell – Send Multiple Email Attachments using Send-MailMessage

Pass each attachment location to a variable and add this to the Attachments parameter separated by comma


Send-MailMessage -To abc@tkr.com - From xyz@tkr.com -Subject "Attachments" -Attachments $Att1,$Att2

Manage Storage of IIS Log Files – Scheduled Deletion of IIS Logs

Drive Space Full with IIS Log Files / Reclaim Disk Space

Are your Local Drives of your IIS Server running out of space? Have you checked the size of your IIS Logs?

If your IIS was setup by a professional; you would not have to go through this issue. The log files would have been managed appropriately

Ideally I do not see a purpose to keep IIS Log files beyond a period of 1 month. Those older than one month should ideally be removed to prevent disk space issues

I found below posts which will assist you. Before you use the below scripts; please identify the location of your log files

Using Powershell


Using VBScript


By default; you would find them on C:\inetpub\logs\LogFiles\

To verify the location; open IIS and select the Default Website and click Logging


Take note of the path mentioned in the directory field


Powershell – Export-Csv to export multi-valued attributes

Passing Mutliple Variables to Export-CSV cmdlet

If you have overcome a situation where-in; while exporting results using Export-CSV; multi-valued columns return just the property System.String[]; I have just the right solution for you

If the multi-valued column name is recipients; use the column as below

@{Name=’recipients’;Expression={[string]::join(“;”, ($_.recipients))}}


Powershell Error – Index was outside the bounds of the array when using System.Net.Mail Class with Send-MailMessage cmdlet

Are you using the System.Net.Mail to send File Attachments? Is the file attachment above 3MB?

If yes; you have just found out the reason for the error. The System.Net.Mail Class throws an exception if a file attachment is over 3MB

Microsoft has a patch available which solves this issue


If you have any issues downloading the file; you may post your comment on this post.

Once the patch is applied; you should now be able to send large attachments using your Powershell Send-MailMessage cmdlet.

Please ensure that you use the -UseSSL in your cmdlet. If you leave out -UseSSL; you are most likely to encounter the below error

Send-MailMessage : The operation has timed out.