Dropdown list - pull defined data per item RRS feed

  • Question

  • Hello all!

    I am writing a little tool for Exchange purposes in Powershell.

    That what I want to achieve is when I select domain controller from list system automatically will pull predefined remaining credentials data basing on which domain controller is selected. Action is triggered by 'load credentials' button.

    I wanted to this via function but I guess I am doing something wrong.

    Kindly please for help - here is the code:

    $Servers = @("SERVER1.contoso.com","SERVER2.contoso.world","SERVER3.contoso.eu")
    $LoadCred = New-Object System.Windows.Forms.Button
            $LoadCred.Location = New-Object System.Drawing.Size(13,110)
            $LoadCred.Size = New-Object System.Drawing.Size(120,25)
            $LoadCred.Font = "Times New Roman, 8"
            $LoadCred.Text = "LOAD CREDENTIALS"
            function Choice_1 { if ($DropDown.Items.Item("2")) {

        $PassBox = "Password"
        $DomainLogBox = "User-in-Kiev"
    foreach ($Item in $servers) { $DropDown.Items.Add($Item) }

    Wednesday, October 18, 2017 8:25 AM

All replies

  • OK I have found the mistake!

    Here is a proper code - it works now! :)

    function Ukraine {
    if ($DropDown.Items.Item("2")) {

    Wednesday, October 18, 2017 10:42 AM
  • Hi,

    Good to hear that you have solved this issue by yourself. In addition, thanks for sharing your solution in the forum as it would be helpful to anyone who encounters similar issues.

    If there is anything else we can do for you, please feel free to post in the forum.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, October 19, 2017 1:29 AM