Combobox won't populate after packaging

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 8 years and 5 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
User avatar
wayne_Avery
Posts: 30
Last visit: Tue Feb 01, 2022 2:25 pm

Combobox won't populate after packaging

Post by wayne_Avery »

Stats
Powershell Studio 2012
Version 3.1.35
Windows 7 64 bit

I have made a form with a combobox that populates from an arraylist. The list is a bunch of samAccountNames from AD. In design it works fine however when I package the project the Combobox fails to populate. Any ideas what I may be missing? Code as follows:

Code: Select all

$group = [ADSI] "LDAP://CN=ADSecurityGroup,OU=xx,DC=xx,DC=xx,DC=xx" 
$group.cn
$myArrayList = New-Object System.Collections.ArrayList
$group.cn  
    foreach ($member in $group.member) 
        { 	
            $Uname = new-object directoryservices.directoryentry("LDAP://$member") 
			$myArrayList .Add($Uname.samAccountName)
            $Uname.samAccountName 
        }
		$myArrayList = $myArrayList | sort
		Load-ComboBox $cboUserList $myArrayList -Append
Thanks
Wayne
User avatar
SAPIEN Support Forums
Posts: 945
Last visit: Thu Oct 22, 2015 1:10 pm

Combobox won't populate after packaging

Post by SAPIEN Support Forums »

This is an automated post. A real person will respond soon.

Thank you for posting, wayne_Avery.

Did you remember to include the following?
  • 1. Product, version and build (e.g. Product: PowerShell Studio 2014, Version & Build: 4.1.71. Version and build information can be found in the product's About box accessed by clicking the blue icon with the 'i' in the upper right hand corner of the ribbon.)
    2. Specify if you are running a 32 or 64 bit version
    3. Specify your operating system and if it is 32 or 64 bit.
    4. Attach a screenshot if your issue can be seen on the screen
    5. Attach a zip file if you have multiple files (crash reports, log entries, etc.) related to your issue.
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***
User avatar
wayne_Avery
Posts: 30
Last visit: Tue Feb 01, 2022 2:25 pm

Re: Combobox won't populate after packaging

Post by wayne_Avery »

Since posting this yesterday I have found that my compiled powershell script (and combobox) actually works as it should if I run it from a local drive. The combobox still refuses to populate if ran from a network drive. Any suggestions appreciated.

Regards
Wayne
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Combobox won't populate after packaging

Post by davidc »

I moved this post to the PowerShell GUIs forum in hopes that an AD expert can chime in.

David
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox won't populate after packaging

Post by jvierra »

How are you running this when you say you are running it from a network drive?

There is no difference in Windows in how a form works when run from a local versus a UNC location assuming nothing is wrong with your installation and no Group Policy or permissions are blocking youo.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox won't populate after packaging

Post by jvierra »

The following approach would be less prone to errors.
PowerShell Code
Double-click the code block to select all.
$group = [ADSI] "LDAP://CN=ADSecurityGroup,OU=xx,DC=xx,DC=xx,DC=xx"
$members=foreach ($member in $group.member) {
	[adsi]"LDAP://$member"
}
$cboUserList.DataSource = [collections.arraylist]@($members)
$cboUserList.DisplayMember='SamAccountName'
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox won't populate after packaging

Post by jvierra »

Here is a demo of a method that will function correctly on all servers and workstations.

Edit the group path and build to test.
Attachments
Demo-ComboBoxGroupMembers.psf
(17.98 KiB) Downloaded 167 times
User avatar
wayne_Avery
Posts: 30
Last visit: Tue Feb 01, 2022 2:25 pm

Re: Combobox won't populate after packaging

Post by wayne_Avery »

Many thanks for assistance but today we worked it out. Our environment is transitioning to a new domain. If I put the executable on a server in the same domain as where I am calling AD it worked fine. It will have something to do with trusts between the 2 domains but I needn't bother at this point as the migration should be completed soon.
Cheers
Wayne
This topic is 8 years and 5 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