Hi Below is the error i am getting while running the powershell script Error
Cannot find an overload for "PeopleManager" and the argument count: "1
Script:
#Importing PowerShell Module
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
#Authenticating User to SharePoint Online
$username = "[email protected]"
$Adminurl = "https://sp-admin.sharepoint.com/sites/Dev"
$siteColUrl = "https://test365dev.sharepoint.com"
#Logging Method for errors
$DATE = get-date
$LogPath = "logpath"
$LogFileName = "LogFileName.log"
$FilePath = $LogPath +"\" + $LogFileName
$logFileCreated = $False
function write-log([string]$label, [string]$logMsg)
{
if($logFileCreated -eq $False)
{
write-host "Creating log file..."
if((Test-Path -path $LogPath) -ne $True)
{
write-host"Provide proper values to LogPath folder" -ForegroundColor Red
}
else
{
Add-Content -Path $FilePath -Value $logHeader
$script:logFileCreated = $True
write-host "Log file created..."
[string]$info = [System.String]::Format("[$Date] {0}: {1}",$label, $logMsg)
Add-Content -Path $FilePath -Value $info
}
}
else
{
[string]$info = [System.String]::Format("[$Date] {0}: {1}",$label, $logMsg)
Add-Content -Path $FilePath -Value $info
}
}
try
{
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.UserProfiles.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Bind to site collection
$password = Read-Host -Prompt "Enter password" -AsSecureString
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($siteColUrl)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username,$Password)
$Context.Credentials = $Creds
Write-Host "Successfully connected.." -ForegroundColor Green
#Retrieve lists
$web = $Context.Web
$Users = $Context.Web.SiteUsers
$Context.Load($Users)
$Context.Load($web)
$Context.ExecuteQuery()
$PeopleManager = New-Object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($Context)
Foreach ($User in $Users)
{
$UserProfile = $PeopleManager.GetPropertiesFor($User.LoginName)
Write-Host "user profile value: " + $UserProfile
$Context.ExecuteQuery()
If ($UserProfile.Email -ne $null)
{
Write-Host "User:" $UserProfile.Email -ForegroundColor Green
$UserProfile.UserProfileProperties
}
}
}
catch
{
write-log "Error: " $_.Exception.Message
}
Import-Module
) but the rest of the script ran fine for me...