Call a function within a message box, timer
<p>I have a timer that I setting up for one of my scripts, I have all of the pieces setup but cannot seem to get the timer to call within the box, it will call in powershell and then bring up the box. What I am looking to do is have it countdown for 2 minutes then close. Below is my code </p>

<pre><code>[void] [System.Reflection.Assembly]::LoadWithPartialName ("System.Drawing") 
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 

$x = 2*60
$length = $x / 100

Function timer () 
{While($x -gt 0) {
$min = [int](([string]($x/60)).split('.')[0])
$text = " " + $min + " minutes " + ($x % 60) + " seconds left"
Write-Progress "Building Account" -status $text -perc ($x/$length)
start-sleep -s 1
$x--
}
}


$objForm = New-Object System.Windows.Forms.Form 
$objForm.Text = "Timer Example"
$objForm.Size = New-Object System.Drawing.Size(330,380) 
$objForm.StartPosition = "CenterScreen"

$lblLog = New-Object System.Windows.Forms.Label
$lblLog.Location = New-Object System.Drawing.Size(10,230) 
$lblLog.Size = New-Object System.Drawing.Size(80,20) 
$lblLog.Text = timer

$objForm.Controls.Add($lblLog) 

$objForm.Add_Shown({$objForm.Activate()})

[void] $objForm.ShowDialog()
</code></pre>