Page 1 of 1

Guis & Active Directory

Posted: Tue Jun 20, 2023 4:19 am
by MikeLaing
Hi,

I'm using the following:

Product: PowerShell Studio 2023 (64 Bit)
Build: v5.8.223
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19045.0

I'm trying to write my very first forms project as an assist to our Service Desk.

I have a Multi form project with a main form and one called Reset password. I've setup a button and the click event code is the following:
  1. $btnLookup_Click={
  2.     #TODO: Place custom script here
  3.     if (($txtCallNumber.Text -ne $null) -and ($txtUsername.Text -ne $null))
  4.     {
  5.         $LookupUser = $null
  6.         $LookupUser = Get-ADUser -Filter 'SAMAccountName -eq "$($txtUsername.Text)' -Properties Mail
  7.        
  8.         If (($LookupUser | Measure-Object).Count -eq 1)
  9.         {
  10.             $txtName.Text = $LookupUser.Name
  11.             $txtEmail.Text = $LookupUser.Mail
  12.         }
  13.     }
  14. }
I know the code works as I've put it into PowerShell to make sure. However the only thing the form does is close !

Any help would be appreciated.