Importing Modules

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
Reddrgn2
Posts: 8
Joined: Wed May 23, 2018 6:13 am

Importing Modules

Post by Reddrgn2 » Mon Jul 01, 2019 7:18 am

Product, version and build: Primal Studio 2019
32 or 64 bit version of product: 64
Operating system:win 10 pro
32 or 64 bit OS: 64

I have tried to search before creating this topic, cause I am sure i missed something somewhere.

Issue - when trying to run a few basic built exe's they open with no issue but doing the actual work (getting the info) they fail on other user computers.

I build 2 gui's to get basic AD user info, one looks at emp number and the second looks at display name. It get name, title, emp#, upn, description.

I built them for practice and whiny people complaining about having to open "AD users and computers, then searching"

I have tested them on my computer and work fine. I have tested on a pc used for testing, works fine.

A few users are not able to get them to display results, just shows the loading page.

I have tried a few options to get it to work.

Try 1 - when opening the exe(built exe as powershell- v2 host windows forms for either 32 or 64b, no restrictions on os), it runs import-module activedirectory
-works on my and testing - other pc's half the people it works

Try 2 - on the form i created another button to run import-module activedirectory - (built exe as powershell- v2 host windows forms for either 32 or 64b, no restrictions on os), it runs import-module activedirectory
-works on my and testing - other pc's half the people it works

One of my questions is - for the button to import the AD module - should there be anything else with the command? Any ideas that I might be missing or didn't do correctly? I would like to have all the users that will be using the tools upgrade their powershell versions to 5 but thats another issue to deal with. Right now most are at PS version 2. Side note, testing pc is win 7(64b, ps version 2)-able to run gui's, another win 10(64b, ps version 5.1)-not able to really run gui's.

Here is the code for the form with the button

Code: Select all

$formGetEmpInfoFromDispla_Load={
#TODO: Initialize Form Controls here
#Import-Module ActiveDirectory
}

$buttonFind_Click={
#TODO: Place custom script here
$displayname = $textboxdisplayname.Text
$labelDisplayUserInfo.Text = Get-ADUser -Filter "name -like '$displayname'" -Properties Name, SAMAccountName, Enabled, description, title, SID, UserPrincipalName, employeeID, ScriptPath, HomeDirectory | Format-List -Property Name, SAMAccountName, EmployeeID, Enabled, Description, Title, UserPrincipalName, ScriptPath, HomeDirectory, SID | Out-String

}

$buttonLoadADModule_Click={
#TODO: Place custom script here
Import-Module ActiveDirectory
}

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: Importing Modules

Post by davidc » Mon Jul 01, 2019 8:12 am

[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
David
SAPIEN Technologies, Inc.

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: Importing Modules

Post by davidc » Mon Jul 01, 2019 8:17 am

For the Windows 10 machines, I recommend generating a package executable engine targets V5 and see if that works.

I also recommend using the PassThru parameter to verify that the module was indeed loaded:

Code: Select all

$module = Import-Module ActiveDirectory -PassThru

if (-not $module)
{
	#Show error message
}
David
SAPIEN Technologies, Inc.

User avatar
Reddrgn2
Posts: 8
Joined: Wed May 23, 2018 6:13 am

Re: Importing Modules

Post by Reddrgn2 » Mon Jul 01, 2019 8:52 am

Building both for PS version 5 worked for the windows 10.

PC's with PS version 2 still having issues, even though built for PS version 2 - it not all but some .

Added the pass though and not giving error one that it does not work on, just sits there.

User avatar
jvierra
Posts: 13682
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Importing Modules

Post by jvierra » Mon Jul 01, 2019 10:16 am

Start by just running the script on the machines that fail and look at the scripts result. You are likely getting an error that you cannot see.

Locked