I am trying to connect to the Microsoft.SharePoint.Client.UserProfiles.dll however keep getting the message -
New-Object : Cannot find an overload for "PeopleManager" and the argument count: "1".
At line:26 char:18
+ ... leManager = New-Object Microsoft.SharePoint.Client.UserProfiles.Peopl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
The script is this test script here which just picks up all user profiles and writes each one out (got this from here)
#Specify tenant admin and URL
$User = "USERACCOUNT.onmicrosoft.com"
#Configure Site URL and User
$SiteURL = "https://TENANT-admin.sharepoint.com"
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.UserProfiles")
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
#Bind to Site Collection
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Context.Credentials = $Creds
#Identify users in the Site Collection
$Users = $Context.Web.SiteUsers
$Context.Load($Users)
$Context.ExecuteQuery()
#Create People Manager object to retrieve profile data
$PeopleManager = New-Object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($Context)
Foreach ($User in $Users)
{
$UserProfile = $PeopleManager.GetPropertiesFor($User.LoginName)
$Context.Load($UserProfile)
$Context.ExecuteQuery()
If ($UserProfile.Email -ne $null)
{
Write-Host "User:" $User.LoginName -ForegroundColor Green
$UserProfile.UserProfileProperties
Write-Host ""
}
}
I have tried the following - change the URL
I thought maybe they couldn't find the reference to the DLL but I can see powershell is picking them up
They are also here if I reference them directly as I downloaded the SDK for SP online
If anyone has any pointers I would be grateful.
Thanks