Welcome › Forums › General PowerShell Q&A › Sapien
- This topic has 1 reply, 1 voice, and was last updated 3 years, 4 months ago by
Participant.
Viewing 1 reply thread
-
AuthorPosts
-
-
August 12, 2016 at 3:01 pm #50160
Hello, I'm new to Sapien and have a question that can probably be answered here...
I have a list box I'm trying to keep updated with our locked out users, I want this listbox to be updated every 5 seconds or so.
They have a prebuilt function for generating the contents of a list box, but i'm not sure where I would stick code to continuously update it...
I have it generate the listbox on load as seen below, but where would i Stick some code to do like a
do { #$lockedlist is a checkedlistbox form object Load-ListBox $LockedList (Search-ADAccount -LockedOut) "name" start-sleep 5 } while (1 -eq 1)
Complete code below..
$form1_Load={ #TODO: Initialize Form Controls here Load-ListBox $LockedList (Search-ADAccount -LockedOut) "name" } #region Control Helper Functions function Load-ListBox { Param ( [ValidateNotNull()] [Parameter(Mandatory=$true)] [System.Windows.Forms.ListBox]$ListBox, [ValidateNotNull()] [Parameter(Mandatory=$true)] $Items, [Parameter(Mandatory=$false)] [string]$DisplayMember, [switch]$Append ) if(-not $Append) { $listBox.Items.Clear() } if($Items -is [System.Windows.Forms.ListBox+ObjectCollection] -or $Items -is [System.Collections.ICollection]) { $listBox.Items.AddRange($Items) } elseif ($Items -is [System.Collections.IEnumerable]) { $listBox.BeginUpdate() foreach($obj in $Items) { $listBox.Items.Add($obj) } $listBox.EndUpdate() } else { $listBox.Items.Add($Items) } $listBox.DisplayMember = $DisplayMember } #endregion
-
August 12, 2016 at 3:57 pm #50164
Got it by adding a timer to the form
$form1_Load={ #TODO: Initialize Form Controls here Load-ListBox $LockedList (Search-ADAccount -LockedOut) "name" # timer1 # $timer1.Enabled = $True $timer1.Interval = 3000 $timer1.add_Tick($timer1_Tick) }
$timer1_Tick={
#TODO: Place custom script here
Load-ListBox $LockedList (Search-ADAccount -LockedOut) "name"
}
-
-
AuthorPosts
Viewing 1 reply thread
- The topic ‘Sapien’ is closed to new replies.