Hi Anyone,
1) I work for a large organisation (NHS of over 15,000 Users). I need to be able to Set the Values of various Properties for a User via Sharepoint online e.g. "i:0#.f|membership|user@company.co.uk" However the script below does not throw any error but does not Update the About me neither just not doing anything.
2) Eventually I need to be able to update thousands of Users once this script has been diagnosed properly. would I need to first export all users from Active Directory into an excel spreadsheet, Import the spreadsheet into PowerShell before running the scripts below once diagnosed and corrected to update those Properties and their corresponding values OR is there another way of interrogating all SharePoint users directly and updating the property values you have specified in the script.
Could anyone please help me in anyway including customizing the script properly
Thanks for the effort.
---------------------------------------------------------------------------------------------------------------------
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"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Search.dll"
$siteURL = "https://royalfree-admin.sharepoint.com"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
#Setting Credentials for o365 - Start
$userId = "user@company.co.uk"
$pwd = Read-Host -Prompt "Enter password" -AsSecureString
$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userId, $pwd)
$ctx.credentials = $creds
#Setting Credentials for o365 - End
# Update User Profile property (office 365)
function SetSingleValueProperty(){
try{
$peopleManager = New-Object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($ctx)
$peopleManager.SetSingleValueProfileProperty("i:0#.f|membership|user@company.co.uk", "AboutMe", "Hello and welcome to sharepoint online, hope all is well")
$ctx.Load($peopleManager)
$ctx.ExecuteQuery()
Write-Host "Property updated"
}
catch
{
Write-Host "$($_.Exception.Message)" -foregroundcolor Red
}
}