Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Overview of this book

Table of Contents (22 chapters)
Microsoft Exchange 2010 PowerShell Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating calendar items


Imagine that you have a monitoring script written in PowerShell that checks memory, CPU, or disk utilization on all of your Exchange servers. In addition to alerting your team of any critical problems via e-mail, it might also be nice to schedule a reminder in the future for non-critical issues by creating a calendar item in one or more mailboxes. The EWS Managed API makes it easy to create a calendar item through PowerShell with just a few commands.

How to do it...

  1. First, load the assembly, create the ExchangeService object, and connect to EWS:

    Add-Type -Path C:\EWS\Microsoft.Exchange.WebServices.dll
    $svc = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService
    $svc.AutoDiscoverUrl("[email protected]")
  2. Next, create a new Appointment object:

    $appt = New-Object -TypeName `
    Microsoft.Exchange.WebServices.Data.Appointment `
    -ArgumentList $svc
  3. Fill out the subject and body for the appointment:

    $appt.Subject = "Review Disk Space Utilization on Server(s)"
    $appt...