Showing posts with label Userprofile. Show all posts
Showing posts with label Userprofile. Show all posts

Access profile pictures on SharePoint /OneDrive/Office365

I had recently been asked by one of my companies HR representative to provide the profile photo for all the users in the company.

Now there are many ways you can find these photos. Our organization uses Azure Active directory and office 365.

Found this very useful blog online which describes how these Photos are synched. https://paulryan.com.au/2016/user-photos-office-365/

After going through few more blogs, found a very easy way to get all the profile pictures. Basically, there is a hidden picture library in OneDrive called 'User Photos' where all the profile pics are stored. You can access this library by using following url:
https://<yourtenant>-my.sharepoint.com/User%20Photos/Forms/Thumbnails.aspx

For Onpremise SharePoint installation, just replace your tenant name with mysite:
https://<mysite>/User%20Photos/Forms/Thumbnails.aspx 



Create SharePoint user profiles using powershell

I have been recently asked to create thousands of user profiles in our test environment.

Ideally importing profiles from AD or provisioning the profiles is advisable, but due to nature of our test environment it was not possible. After searching a bit, I found a script and modified it for this purpose. The script requires all the profile related data to be stored in a CSV.

#Add-PSSnapin if not added already using this link 

$portalsite = "http://spportal"
$portalcontext = Get-SPServiceContext -Site $portalsite


$upm = New-Object -TypeName Microsoft.Office.Server.UserProfiles.UserProfileManager -ArgumentList $portalcontext
$userslist = Import-Csv -Path "userprofilelist.csv"

#Loop through all the rows of csv

for($count=0; $count -lt $userslist.Count; $count++)
{

#Create new User Profile
$upm.CreateUserProfile($userslist[$count].UserName)
$profileproperty = $upm.GetUserProfile($userslist[$count].UserName)

#Custom User Profile being updated for the user
$profileproperty["property1"].Value = $userslist[$count].Property1
$profileproperty["property2"].Value = $userslist[$count].Property2
$profileproperty["property3"].Value = $userslist[$count].Property3
$profileproperty.Commit()

}

Hope this helps. Please see my other scripts to export the data to CSV.