Guis & Active Directory

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 1 year and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
MikeLaing
Posts: 1
Last visit: Tue Jun 20, 2023 7:28 am

Guis & Active Directory

Post 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.
This topic is 1 year and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked