Hi all,
I’m working on some deployment scripts for Office 365 using PowerShell and CSOM. However, when I try to load the SharePoint 2013 libraries, I get the following error:
Add-Type : Could not load file or assembly ‘file:///C:\Users\…\Microsoft.SharePoint.Client.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
Here’s what I’ve tried so far:
- Running Windows PowerShell ISE as Administrator
- Unblocked the DLL’s using the Unblock-File command
- Changed execution policy to RemoteSigned
The SharePoint 2013 DLL’s are .NET version 4.5 (based on JetBrains dotPeek). My PowerShell has the following version:
- PSVersion                 5.0.10130.0
- WSManStackVersion         3.0
- SerializationVersion      1.1.0.1
- CLRVersion                4.0.30319.42000
- BuildVersion              10.0.10130.0
- PSCompatibleVersions      {1.0, 2.0, 3.0, 4.0…}
- PSRemotingProtocolVersion 2.3
Any help would be greatly appreciated.
Thanks,
-Haniel
So as it turns out, I needed to make the following change to my powershell_ise.exe.config file under C:\Windows\System32\WindowsPowerShell\v1.0\
<?xml version=”1.0″?>Â Â Â Â <configuration>Â Â Â Â Â Â Â Â Â <startup useLegacyV2RuntimeActivationPolicy=”true”>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <supportedruntime version=”v4.0.30319″/>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <supportedruntime version=”v2.0.50727″/>Â Â Â Â Â Â Â Â Â </startup>Â Â Â Â Â Â Â Â Â <runtime>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <loadfromremotesources enabled=”true”/>Â Â Â Â Â Â Â Â Â Â </runtime></configuration>
Happy scripting!