I am having problem loading the iTextSharp.dll in PowerShell. Sometimes it works fine using either:
[System.Reflection.Assembly]::LoadFrom("C:\dll\itextsharp.dll")
Add-Type -Path C:\dll\itextsharp.dll'
However, most times I get the following error:
Exception calling "LoadFrom" with "1" argument(s):
"Could not load file or assembly 'file:/// C:\dll\itextsharp.dll'
or one of its dependencies. Operation is not supported.
(Exception from HRESULT: 0x80131515)"
At line:1 char:1
+ [System.Reflection.Assembly]::LoadFrom("itextsharp.dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileLoadException
I have tried unblocking the file but I still get the error above.
Looks like this on StackOverflow will probably solve your problem. Apparently you need to add the option <loadFromRemoteSources enabled="true" /> to the .EXEs config file to load an assembly from a network share.
I found this by searching for the HRESULT 0x80131515
I have found that the DLL works with PowerShell ISE (x86), but not the 64-bit version of PowerShell ISE.
Related
I installed PSFramework on my W2k12 server. However when I run an import-module PSFramework I get the following error:
Exception calling "InvokeGlobal" with "0" argument(s): "Parameter count mismatch."
At C:\Program Files\WindowsPowerShell\Modules\psframework\1.6.181\PSFramework.psm1:7348 char:2
+ $isInstalled = $provider.IsInstalledScript.InvokeGlobal()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : TargetParameterCountException
This works fine on my Win 10 machine.
Any ideas?
Thanks in advance,
Jake.
I'm the maintainer of PSFramework, sorry about that fail!
One of my security-related feature updates broke PSv3 & PSv4 support, I didn't notice right away and then was drowned in heavy workload to fix it timely.
I've added an issue that you can track until it is resolved:
https://github.com/PowershellFrameworkCollective/psframework/issues/474
In the meantime, you can resolve this on your server by updating its PowerShell to v5.1 as Mathias suggested, which will resolve it right away.
I've tried a couple of solutions to unzip a file containing the path:
\Content\F_C\Jenkinsworkspace\workspace\BUILD.PROJECT.GENERICS\PROJECT_Generics\PROJECT.Generics\PROJECT.Generic\obj\Debug\Package\PackageTmp
but I get the error:
Exception calling "ExtractToFile" with "3" argument(s): "Could not find a part of the path
Expand-Archive -LiteralPath F:\Jenkinsworkspace\workspace\BUILD.GENERIC.GENERICS\GENERIC.Generic.zip -DestinationPath F:\Jenkinsworkspace\workspace\BUILD.GENERIC.GENERICS\UNZIPED2 -Force
Exception calling "ExtractToFile" with "3" argument(s): "Could not find a part of
the path 'F:\Jenkinsworkspace\workspace\BUILD.GENERIC.GENERICS\UNZIPED2\Content\
F_C\Jenkinsworkspace\workspace\BUILD.GENERIC.GENERICS\GENERIC_Generics
\GENERIC.Generics\GENERIC.Generic\obj\Debug\Package\PackageTmp\modules\
_protected\EPiServer.GoogleAnalytics\EPiServer.GoogleAnalytics.zip'."
At
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:1033 char:25
+ ... [System.IO.Compression.ZipFileExtensions]::ExtractToFile( ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DirectoryNotFoundException
I'm guessing it's because I have a zip within a zip.
In our case, though the path was short, we were getting the same error.
Sharing our solution which might be useful for someone.
We were trying to unzip the package on our application server through powershell script. Basically powershell script runs on our build server & remotely connect to our application server. It was then trying to unzip the package present on application server.
The above scenario was working fine for quite some time before it starts to throw the error during unzipping.
Solution:
We found the reason was anti virus policy, which was blocking the unzipping through remote powershell script.
Soved using this Blog :
https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/
changing the group policy solved the problem
These lines:
"[Environment]::Is64BitProcess"
"[Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
"
gives these results:
True
Exception calling "LoadFile" with "1" argument(s): "The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)"
At C:\GitRepo\PowerShellScripts\ApiDllTest.ps1:11 char:1
+ [Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : BadImageFormatException
The DLL is supplied by the ERP manufacture (Infor M3) and I'm trying to use it to send transactions to the ERP from a PowerShell program I've created. Since I'm not a system admin but instead just a nerd that supports the ERP, I'm actually clueless as to what I'm doing related to the DLL. Google has gotten me this far but i can't get beyond this error. The same error returns when I attempt to use the non x64 version.
Thanks for your wisdom. All suggestions are appreciated.
These statements:
[Environment]::Is64BitProcess
[Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
Generate:
True
Exception calling "LoadFile" with "1" argument(s): The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)
At C:\GitRepo\PowerShellScripts\ApiDllTest.ps1:11 char:1
+ [Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : BadImageFormatException
From a PowerShell program I've written, I am trying to send transactions to the ERP system (Infor's M3) via a DLL for APIs. The DLL is provided by the manufacture. Since I am not a system admin but just a nerd supporting the ERP system, I'm clueless as to what I'm doing and have gotten this far with Google but can't get any further. Your suggestions will be greatly appreciated.
I created a PowerShell automation script and I gave it to my friend when he run it, it said
Method invocation failed because [mshtml.HTMLBodyClass] does not contain a method
named 'getElementsByClassName'.
At C:\Users\עמית\Documents\asaf.ps1:22 char:3
+ $a=$docs.body.getElementsByClassName("FadeOut-Scroll")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
why is that happened?
We both have IE11, .net 4.5, Visual studio, but I have that function and he not.
And it looks like here in his computer the IE console have the function:
but PowerShell does not:
How to update PowerShell?
Found after alot of time:
the missing want microsoft core xml