I have a loop that run when i press a button until a condition is meet.
so i want to use the Marquee animation but i cant figure out how to use it?
Marquee
Indicates progress by continuously scrolling a block across a ProgressBar in a marquee fashion. Use Marquee when you can’t specify a quantity of progress, but still need to indicate that progress is being made. Use the MarqueeAnimationSpeed property to control the speed of the ProgressBar.
here the button code:
Code: Select all
$buttonRemove_Click = {
if ([System.Windows.Forms.MessageBox]::Show("Continue removing: $cmdevice from $global:TargetCollection", "Warning", [System.Windows.Forms.MessageBoxButtons]::OKCancel) -eq "OK")
{
$statusbar1.Text = "Removing Device: $cmdevice from collection: $global:TargetCollection"
Remove-CMDeviceCollectionDirectMembershipRule -CollectionId "$($(Get-CMCollection -Name "$global:TargetCollection").CollectionID)" -ResourceId $SelectedCM
$progressbar1.Style = 'Marquee'
$progressbar1.Step = 1
$progressbar1.Value = 0
$progressbar1.Maximum = 100
DO
{
$a
$a++
Start-Sleep -Seconds 1
Write-Host "$a"
$statusbar1.Text = "Removing Device Pending: $cmdevice - $a"
$progressbar1.Style = 'Marquee'
$progressbar1.Visible = $true
$progressbar1.Refresh
$progressbar1.Value += 1
$Check = Get-CMCollectionMember -CollectionName "$global:TargetCollection" -Name "$cmdevice"
}
Until (!$Check)
$progressbar1.Visible = $false
Refreshdatagridview
$statusbar1.Text = "Removing Device: $cmdevice - DONE"
$date = Get-Date
$message = ("Device: $cmdevice was removed from collection: $global:TargetCollection by $Name - $($env:UserName) - $date")
Write-Host "$message"
Write-log -message ("$message") -component "$($env:UserName)" -Severity 1 -Function "$($MyInvocation.MyCommand)"
}
else
{
$statusbar1.Text = "User cancelled device $cmdevice removal from: $global:TargetCollection"
}
}