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
Get-Outlookappointments
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.
Script
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 $session.Logon() $apptItems = $session.GetDefaultFolder(9).Items $apptItems.Sort("[Start]") $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; } } Get-OutlookAppointments
i need to get shared mailbox details. where i need to modify using this script?
Pingback: Episode 187- Teresa “ScriptingWife” Wilson and Staci “HalsWife” Rottenberg | PowerShell.org
Very Good Job. Is it possible to get Location too ?
Pingback: Never miss an appointment again with PowerShell – Virtu-Al.Net | Soyka's Blog
many thanks, helped a lot!
Pingback: Episode 187- Teresa “ScriptingWife” Wilson and Staci “HalsWife” Rottenberg « PowerScripting Podcast
Great stuff..
Now that’s awesome! Too bad I use powershell from the different customer’s own systems.
SO AWESOME!