PowerShell Code
Double-click the code block to select all.$LastLogonButton_OnClick= { $results.Text=$logons=@() [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().DomainControllers | ForEach{ $logonInt=(Get-Aduser -Filter "sAMAccountName -eq '$($EntryBox.text)'" -server $_.Name -properties lastlogon).lastlogon $logons+=[datetime]::FromFileTime($logonInt) } $newestLogon=($logons| Measure-Object -Max).Maximum $newestLogon | Out-String $results.Focus() }I have other buttons running different scripts using the same output window, they display fine. If I change it to
PowerShell Code
Double-click the code block to select all.$LastLogonButton_OnClick= { $results.Text=$logons=@() [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().DomainControllers | ForEach{ $logonInt=(Get-Aduser -Filter "sAMAccountName -eq '$($EntryBox.text)'" -server $_.Name -properties lastlogon).lastlogon $logons+=[datetime]::FromFileTime($logonInt) } $newestLogon=($logons| Measure-Object -Max).Maximum $newestLogon | Out-file c:\temp\lastlogon.txt() }It creates a text file and populates it with the results I am looking for.
If I run this query, set to display on screen, I get no output and no errors. What am I missing?
For reference, here is the script behind one of the other buttons, this one works perfectly
PowerShell Code
Double-click the code block to select all.$IDSearchButton_OnClick= { $results.Text=Get-ADUser -Filter "sAMAccountName -eq '$($EntryBox.text)'" -Properties DisplayName, sAMAccountName, mail, lastlogondate, extensionattribute5, PasswordLastSet, PasswordExpired, PasswordNeverExpires, buMemberOf, msExchOmaAdminWirelessEnable | Out-String $results.Focus() }