Hi
I currently have a form that displays a progress bar - the idea is to get this progress bar moving along as and when the percentage value passed to it from a job, however I feel a bit out of my depth here....
I am using register-engineevent and new-event to enable the percentage value to be passed up the chain - I can manually query the value and get it returned no problem - the issue is that I need the progress bar to take this value ideally as and when it changes, or on a timer if this isnt possible, and have the form remain usable while this is happening. If I use wait-event, will this essentially pause the form?
Here is my code:
$GetImagingProgress = {
param ([string]$PCID)
process {
Register-EngineEvent -SourceIdentifier Progress -Forward
Add-PSSnapin "Microsoft.BDD.PSSNAPIN"
New-PSDrive -Name MDT -Root \\mdtserver\DeploymentShare$ -PSProvider MDTPROVIDER
DO{$ImagingProgress = Get-MDTMonitorData -Path MDT: | Where-Object { $_.Name -eq $PCID }
$ImagingPercentageDone = $ImagingProgress.PercentComplete
New-Event -SourceIdentifier Progress -MessageData $ImagingPercentageDone
Start-Sleep 3}
While($ImagingPercentageDone -ne 100 -or $ImagingProgress -eq $null)
}
}
$job = Start-Job -scriptblock $GetImagingProgress -ArgumentList "My-pc" -Name 'GetImagingProgress' -
$progress = Get-Event -SourceIdentifier Progress