Never miss an appointment again with PowerShell

If your anything like me then you spend most of your time in PowerShell and sometimes forget to check your appointments in Outlook, wouldn’t it be great if you could see your Outlook calendar straight in PowerShell ?

After doing a little searching and altering this post, I created a nice function for PowerShell which I called


This function by default will show 7 days worth of items in your PowerShell window, you can pass it some parameters, NumDays will show that number of days appointments….


Or you can specify a star date and end date using the parameters “Start” and “End”.

This makes a great addition to your PowerShell profile so every time you open PowerShell you are reminded of what you have coming up for the next week and you can call the function over and over in your PowerShell session when needed.


Function Get-OutlookAppointments {
	param ( 
			[Int] $NumDays = 7,
			[DateTime] $Start = [DateTime]::Now ,
	      	[DateTime] $End   = [DateTime]::Now.AddDays($NumDays)

	Process {
		$outlook = New-Object -ComObject Outlook.Application

		$session = $outlook.Session

		$apptItems = $session.GetDefaultFolder(9).Items
		$apptItems.IncludeRecurrences = $true
		$apptItems = $apptItems

		$restriction = "[End] >= '{0}' AND [Start] <= '{1}'" -f $Start.ToString("g"), $End.ToString("g")

		foreach($appt in $apptItems.Restrict($restriction))
		    If (([DateTime]$Appt.Start -[DateTime]$appt.End).Days -eq "-1") {
				"All Day Event : {0} Organized by {1}" -f $appt.Subject, $appt.Organizer
			Else {
				"{0:ddd hh:mmtt} - {1:hh:mmtt} : {2} Organized by {3}" -f [DateTime]$appt.Start, [DateTime]$appt.End, $appt.Subject, $appt.Organizer

		$outlook = $session = $null;


9 thoughts on “Never miss an appointment again with PowerShell”

  1. Now that’s awesome! Too bad I use powershell from the different customer’s own systems.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.