Is it possible to wait for MMC

Mar 4, 2014 at 8:47 AM
I want to wait for MMC to finish with an process (Spinner or loading bar). We use both in certain situations so I want to know if there is a cmdlet to wait for it before continuing with the automation script.
Mar 4, 2014 at 9:32 AM
Hi IceBunny,
there are several cmdlet that provide such functionality (done? $true/$false), the choice depends on what state you need to trigger:
universal state of a control or several controls:
# executions stops until a button (enabled, with name 'control name') and a text (with text 'some text') appear or returns $false after 5 minutes
Wait-UiaControlState -SearchCriteria @{name="control name";isenabled=$true;controltype="button"},@{name="some text";controltype="text";automaitonid="3"} -Seconds 300;
# to get the full list of parameters, use the ConvertTo-UiaSearchCriteria cmdlet:
$element | ConvertTo-UiaSearchCriteria -Full
# and avoid using such things (that are changeable from run to run) as processId and nativeWindowHandle
# cmdlets that are specific to a state
# Wait-Uia[ControlType]IsEnabled
# these cmdlets are also specific to a state (isOffscreen)
# Wait-Uia[ControlType]IsVisible
any Get- cmdlet has such functionality
# this piece of code waits for a button (for example, a red cross of the form) that is enable - it's a useless example for a standard form and could be useful only for a form without caption
# if there is no such button during the time selected, the cmdlet throws an exception
Get-UiaButton -Name Close -SearchCriteria @{isenabled=$true} -Seconds 20
the Wait-UiaWindow cmdlet also could perform such a trick!
# the mild version ($true/$false)
Wait-UiaWindow -Name *admin*powershell* -WithControl @{controltype="button";name="close"} -Seconds 100;
# the strict version (returns element(s) or throws an exception)
Get-UiaWindow -Name *admin*powershell* -WithControl @{controltype="button";name="close"} -Seconds 100;
As D. Koontz said, "the choice is yours" :)
Mar 4, 2014 at 10:29 AM
awesomeness, thank you so much! apetrovskiy