Error loading required snapin or module

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
etolleson
Posts: 12
Joined: Thu Feb 21, 2013 4:01 am

Error loading required snapin or module

Post by etolleson » Mon Apr 11, 2016 12:43 pm

Product, version and build: PowerShell Studio 2016 5.2.119.0
32 or 64 bit version of product: 64 bit
Operating system: windows 10 and windows 8.1
32 or 64 bit OS: 64 bit
PowerShell Version: 5.0

When running a project within powershell studio it appears to run with no issues. when I deploy or export the project is when i receive the following error:

Error loading required snapin or module
No snap-ins have been registered for Windows PowerShell version 5.

it has the same error with powershell version 4 as well.

the modules are loaded from the startup.pss and do appear in the ps1 file created by the deploy or export.
the project is called by an exe that was created by AutoIT

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

Re: Error loading required snapin or module

Post by davidc » Mon Apr 11, 2016 2:50 pm

I suspect that this is a platform issue. Make sure the script is running using the same settings as PowerShell Studio. For example, if you have 64 Bit selected in PowerShell Studio, make sure a 64 bit executable is calling the script. Some snapins / modules are platform specific and only run in 64 bit or 32 bit.

David
David
SAPIEN Technologies, Inc.

User avatar
etolleson
Posts: 12
Joined: Thu Feb 21, 2013 4:01 am

Re: Error loading required snapin or module

Post by etolleson » Tue Apr 12, 2016 6:02 am

Hi David,

Was hopping that was it but, I uninstalled AutoIT 3 twice rebooted in between installs and loaded the 64 bit version each time. The error did change for powershell version 5 but not for version 4 for version 5 the error now is:
cannot load windows powershell snap-in
Microsoft.Exchange.Management.PowerShell.Admin because of the
following error: could not load file or assembly
Microsoft.Exchange.Management.Configuration.dll or one of its dependencies.
The system cannot find the file specified.

It still works on powershell studio.

I did create a similar project that work with AutoIT a few years ago on windows 7 I believe was powershell version 3 maybe 4 and powershell studio 2015 at that time.

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

Re: Error loading required snapin or module

Post by davidc » Tue Apr 12, 2016 8:22 am

I'm not familiar with AutoIT. Is it running PowerShell script within its own host? If so you will have to contact AutoIT.

The Exchange snapin uses the .NET 2.0 runtime and any host using a newer .NET runtime requires a config file that allows the application to load legacy assemblies. Without this config file the Exchange snapin will not load.

You can probably get around this by packaging the script into an executable (include the generated config file) and call that from AutoIt.

David
David
SAPIEN Technologies, Inc.

User avatar
etolleson
Posts: 12
Joined: Thu Feb 21, 2013 4:01 am

Re: Error loading required snapin or module

Post by etolleson » Tue Apr 12, 2016 10:46 am

Thanks for the suggestion I tried to build an exe and run and received the following error:

>> Package 'T:\NetworkServices\Shared\TccAccountOperationsO365\scriptsource\TccAccountOperations.psproj'
SAPIEN Package and Deploy Tool 4.0 (c) 2005 - 2016 SAPIEN Technologies, Inc.

Packaging with SAPIEN PowerShell V3 Host (Command line) x64
Adding T:\NetworkServices\Shared\TccAccountOperationsO365\scriptsource\TccAccountOperations.Package.ps1
Writing scripts to TccAccountOperations.exe
Error: Cannot open icon file C:\Program Files\SAPIEN Technologies, Inc\PowerShell Studio 2014\ScriptPackage.ico

>> Completed

User avatar
etolleson
Posts: 12
Joined: Thu Feb 21, 2013 4:01 am

Re: Error loading required snapin or module

Post by etolleson » Tue Apr 12, 2016 10:51 am

I meant to mentioned that I did uninstall and reinstall powershell studio 2016. in both cases I did not find a file structure for 2014 location. Do I need to install 2014 or is there somewhere to change where it looks for the file scriptpackage.ico?

User avatar
etolleson
Posts: 12
Joined: Thu Feb 21, 2013 4:01 am

Re: Error loading required snapin or module

Post by etolleson » Tue Apr 12, 2016 11:25 am

ok I figured out to change the location to where to find the scriptpackage.ico and the exe appears to work for me on my windows 10 powershell version 5 computer but I still get an error on my windows 8.1 powershell version 4 I also had a colleague try the exe and they recieved an error not able to locate the xml file I will work with them tomorrow to see how there machine is setup.

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

Re: Error loading required snapin or module

Post by davidc » Tue Apr 12, 2016 11:42 am

You need select a V3 packager engine in order for it to run it in a PowerShell V4 environment.

David
David
SAPIEN Technologies, Inc.

User avatar
etolleson
Posts: 12
Joined: Thu Feb 21, 2013 4:01 am

Re: Error loading required snapin or module

Post by etolleson » Wed Apr 13, 2016 12:56 pm

I was able to resolve my issue with AutoIT calling the powershell script. I believe it was more user than anything else. While trying to resolve the issue I ran into the following issue.
the first time I tried to run the project as V2 - 64 Bit in powershell studio 2016 the following error happened.

This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

I tried refreshing local cache did not work. left it alone while I went to a meeting then went to my other machine in another office and was able to run strange.

bottom line is I do not know what it is saying about the assembly or how you would go around to fix it. not sure if it would help resolve my issue with powershell version 4 which should work but doesn't only powershell version 5 does.

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

Re: Error loading required snapin or module

Post by davidc » Wed Apr 13, 2016 1:55 pm

This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
This means the module or snapin's binary assembly was writing in a later version of .NET than that of the PowerShell host. In other words, you will need to use a later version of PowerShell in order to load that snapin / module.

Note: PowerShell V2 uses .NET 2.0.

David
David
SAPIEN Technologies, Inc.