Pwoershell Studio 5.4.134 in Sapien Studio
64 bit
64 bit OS
PowerShell Version: v5, v3 same result
I've got a script that loads the active directory module. It then uses it to make changes to AD objects. This works fine when I run it in PS Studio, in an Powershell window, and at the DOS prompt. BUT, when I then compile the code into an EXE, it acts as though the module wasn't loaded.
The code basically boils down to this:
import-module activedirectory
$TargetGroup = "AzureUsers"
$UsersToCheck = Get-ADGroupMember -Identity $TargetGroup
Note the import-module, which doesn't seem to be working in the .EXE. I've tried both Powershell v3 and v5.
EXE not working with Import-Module
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: EXE not working with Import-Module
Please make sure you have the correct platform / bitness selected, because some modules are 64 bit only.
If the script requires admin rights, you might want to use an elevation manifest:
If the script requires admin rights, you might want to use an elevation manifest:
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: EXE not working with Import-Module
Are you getting an error message?
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- 4100260298
- Posts: 5
- Last visit: Fri Aug 03, 2018 9:37 am
Re: EXE not working with Import-Module
Thank you both!
I followed the instructions provided, and they partially resolved the problem. I can run the EXE from explorer, and it works correctly. However, it would not run in the scheduled task. After more troubleshooting, I decided to delete the scheduled task and recreate it. Doing this then resolve the final issue and the EXE is running in the scheduled task as expected.
Thank you both!
I followed the instructions provided, and they partially resolved the problem. I can run the EXE from explorer, and it works correctly. However, it would not run in the scheduled task. After more troubleshooting, I decided to delete the scheduled task and recreate it. Doing this then resolve the final issue and the EXE is running in the scheduled task as expected.
Thank you both!