2

I have this line in my powershell script:

$peopleManager = New-Object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($context)

When it gets hit I receive the error:

New-Object : Cannot find an overload for "PeopleManager" and the argument count: "1".

I am importing these assemblies:

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"

Everything else is working fine. Any ideas what this could be?

3

I believe this error occurs while running the specified code in SharePoint Online Management Shell, right?

SharePoint Online Management Shell is fully compatible with SharePoint Online Client Components SDK but not with SharePoint Server 2013 Client Components SDK

Solution

Make sure assemblies from SharePoint Online Client Components SDK are referenced.

In your case install SharePoint Online Client Components SDK if needed and replace the lines:

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"

with

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"
0

By running the script in windows powershell in administrator mode will execute without errors. Interestingly SP Management Shell runs the script successfully and also fails in random cases, but when you run the same script using windows powershell, execution succeeds in all runs.

  • I don't think this provide the solution to the error of asker. – Aakash Maurya Jul 8 '16 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.