I have upgraded to WINSCP 5.9.5 Automation. My scripts all fail with the Add-type command:
Add-Type : Could not load file or assembly 'file:///C:\Program Files (x86)\WinSCP\WinSCPnet.dll' or one of its dependencies.
Operation is not supported. (Exception from HRESULT: 0x80131515)
After that error, none of the later winscp calls within the script will function.
Someone, please send me some advice on how to resolve this.
New-Object : Retrieving the COM class factory for component with CLSID {2D4EF368-EE80-4C15-AE77-D12AEAF4B00A} failed due to the following error:
80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At line:19 char:19
+ $sessionOptions = New-Object -ComObject WinSCP.SessionOptions -Property @{
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (Smile [New-Object], COMException
+ FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand
Can you please stop skipping between the two topics?
I never wrote that you should not use Add-Type.
I've asked you (in the other topic), why do you instantiate the class via COM - The -ComObject switch.
Though the switch is not anymore in the latest code you have posted. But you didn't show us, what problem (if any) do you have with the latest code. It must be a different problem, than you had with the previous code.
I got it working finally.
My apology for jumping between the 2 posts.
I removed the "Block" on the DLL properties and re-registered it.
I removed the -ComObject.
Before the Add-Type, I do CD to the folder where the DLL is installed.
Now the command is simply the DLL name.