you can double click the clock in the systray to do a quick lookup (I often used it for that) but you need to be an Admin to do so, so it is not available on my own workstation using my normal account , also it shows no week numbers and I often need those also
So this trick did help me out on several occasions, but still this is not a really ideal solution.
Hence I made this small PowerShell function that does show a Calendar with WeekNumbers in a Form that closes again on hitting [Enter], that I load in my profile and alias to Cal to keep it ready for a quick lookup of some dates, as you will be surprised how often it comes handy.
(note the dot-space to load in global scope, and the loading forms library in profile (needed for function)
to test you can also just past the code into the PowerShell console to load the function, and start using the function:
[void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
. c:\PowerShell\Functions\GetCalendar.ps1
and here is the script : (formatted by the html export function from PowerShell Analyzer a great PowerShell editor, if you not know it yet be sure to try it out)
# Function Get-Calendar
# Shows a calendar with WeekNumbers in a Form
# /\/\o\/\/ 2006
# www.ThePowerShellGuy.com
Function get-Calendar {
$form = new-object Windows.Forms.Form
$form.text = "Calendar"
$form.Size = new-object Drawing.Size @(656,639)
# Make "Hidden" SelectButton to handle Enter Key
$btnSelect = new-object System.Windows.Forms.Button
$btnSelect.Size = "1,1"
$btnSelect.add_Click({
$form.close()
})
$form.Controls.Add($btnSelect )
$form.AcceptButton = $btnSelect
# Add Calendar
$cal = new-object System.Windows.Forms.MonthCalendar
$cal.ShowWeekNumbers = $true
$cal.MaxSelectionCount = 356
$cal.Dock = 'Fill'
$form.Controls.Add($cal)
# Show Form
$Form.Add_Shown({$form.Activate()})
[void]$form.showdialog()
# Return Start and end date
return $cal.SelectionRange
}
set-alias cal get-Calendar
So if you are need a quick calendar, you just need ro do a quick cal[enter], in the PowerShell console ..and there you go :
PoSH>cal
End Start
--- -----
10/12/2006 12:00:00 AM 10/12/2006 12:00:00 AM
and you can select a timeframe in the calendar to return.
I added a "hidden" button (size 1 by 1) , to handle the [enter] key to close the Form and return the start and end date, to make the calendar more handy to use, as a quick enter will close the form after use and you do not need to use X to close the form, and I still can use fill on the Calendar control. also you can select a range of days in the Calendar and the function will return the Start and the End date of that period to the PowerShell console when it is closed.
PoSH>$vacation = cal
PoSH>$vacation.endSunday, November 05, 2006 12:00:00 AM
PoSH>$vacation.start
Saturday, October 14, 2006 12:00:00 AM
PoSH>$vacation.end - $vacation.start
Days : 22
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 0
Ticks : 19008000000000
TotalDays : 22
TotalHours : 528
TotalMinutes : 31680
TotalSeconds : 1900800
TotalMilliseconds : 1900800000
Enjoy,
Greetings, /\/\o\/\/
Tags : Monad PowerShell
October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 April 2006 May 2006 June 2006 July 2006 August 2006 September 2006 October 2006 November 2006 December 2006