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.
Locked
User avatar
wayne_Avery
Posts: 27
Joined: Mon Sep 27, 2010 12:43 pm

Combobox won't populate after packaging

Post by wayne_Avery » Mon Oct 19, 2015 5:35 am

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
Joined: Wed Dec 03, 2014 2:26 pm

Combobox won't populate after packaging

Post by SAPIEN Support Forums » Mon Oct 19, 2015 5:35 am

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: 27
Joined: Mon Sep 27, 2010 12:43 pm

Re: Combobox won't populate after packaging

Post by wayne_Avery » Tue Oct 20, 2015 3:55 am

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
Joined: Thu Aug 18, 2011 4:56 am

Re: Combobox won't populate after packaging

Post by davidc » Tue Oct 20, 2015 8:29 am

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: 14021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Combobox won't populate after packaging

Post by jvierra » Tue Oct 20, 2015 9:35 am

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: 14021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Combobox won't populate after packaging

Post by jvierra » Tue Oct 20, 2015 9:40 am

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: 14021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Combobox won't populate after packaging

Post by jvierra » Tue Oct 20, 2015 10:26 am

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 76 times

User avatar
wayne_Avery
Posts: 27
Joined: Mon Sep 27, 2010 12:43 pm

Re: Combobox won't populate after packaging

Post by wayne_Avery » Wed Oct 21, 2015 4:01 am

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

Locked