Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PictureURL

Posted on 2011-09-13
10
Medium Priority
?
469 Views
Last Modified: 2012-05-12
Having 3 webapps:  WebApp1 (CountryA)  + WebApp2 (CountryB) - and a "common" Mysite

I would like that human resource dept. in each country maintain they "own" pictures of the employes by a picture library on each countrys site...

Right now both CountryA and CountryB and the Mysite looks in the picturelibrary that resides on CountryA

I have done by this powershell script:

#My Site URL
$mySiteUrl = "http://mysite/"
 
#The part of the picture URL you are trying to find
$pictureLibUrl = "http://countryA/employesspictures"

#The internal name for PictureURL
$upPictureURLAttribute = "PictureURL"
#The internal name for Login
$LoginAttribute = "AccountName"

 
#Get site objects and connect to User Profile Manager service
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profiles = $profileManager.GetEnumerator()
 
foreach ($userProfile in $profiles) {

  $userLogin = $userProfile[$LoginAttribute].Value.Split('\')[1]
  $newPictureURL = $pictureLibUrl + $userLogin + ".jpg"
  $userProfile[$upPictureURLAttribute].Value = $newPictureURL
  $userProfile.Commit()

  write-host "User: " $userLogin " Picture: " $newPictureURL
} 

Open in new window


How can I accomplish that the common "Mysite" should look in both CountryA and CountryB and that CountryA should look in http://countryA/employepictures AND CountryB should look in http://countryB/employepictures  ??


Hope it makes sense....  
0
Comment
Question by:Aarsleff
  • 5
  • 3
  • 2
10 Comments
 
LVL 16

Expert Comment

by:quihong
ID: 36533488
You can't have it "look in both". You need to add some logic based on another profile field (i.e. office location), and then set the pictureURL field.
0
 

Author Comment

by:Aarsleff
ID: 36533938
Ok...do you have and powershell example (I'm not a programmer)

Btw... The CountryA and CountryB are in different OU's in AD - but both gets imported by the UPS application in SP    

It's to achieved that the Users in CountryA don't have access to CountryB and vice versa.... of course they all have access to the mysite webapp
0
 
LVL 38

Accepted Solution

by:
Justin Smith earned 2000 total points
ID: 36535583
I've never seen this done, not even sure it's possible out of the box.  I'm anxious to see if there will be a solution to this.

Can't the HR people just upload photos directly to the Photo Library on the MySite host site?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Aarsleff
ID: 36536178
Oh..yes... that could be a solution ...will the employees pictures then be displayed on each country webapp if one search for a person within the countryA...?? (the people search has to function as a phonebook.. )
0
 
LVL 38

Expert Comment

by:Justin Smith
ID: 36536329
As long as both web apps are subscribed to the User Profile App, yes.
0
 

Author Comment

by:Aarsleff
ID: 36536440
They are ... so that's the solution then... thanks...  ;)

So I'll just change the script to?:

#My Site URL
$mySiteUrl = "http://mysite/"
 
#The part of the picture URL you are trying to find
$pictureLibUrl = "[b]http://Mysite/employeespictures[/b]"

#The internal name for PictureURL
$upPictureURLAttribute = "PictureURL"
#The internal name for Login
$LoginAttribute = "AccountName"

Open in new window

0
 
LVL 16

Expert Comment

by:quihong
ID: 36538004
I am a little confused on the ultimate goal here.

It sounds like you're okay now to use one photo library for all your employee photos regardless of country. This would be the simplest route. Just make sure that everyone has read access to the library so the photo is correctly displayed in the people search result. Your HR department would have Contributor rights to upload photos.

I would suggest you check if the photo exist before setting it. See code.
foreach ($profile in $upm)
{
   $photoUrl = $portalurl + "/employee photos/" + $profile["EmployeeID"].Value + ".jpg"
   $photoFile = $portalweb.GetFile($photoUrl)

   if($photoFile.Exists) {
      $profile["PictureURL"].Value = $portalurl + "/employee photos/" + $profile["EmployeeID"].Value + ".jpg"
      $profile.Commit()
   }
   else {
      $profile["PictureURL"].Value = $null
      $profile.Commit()
   } 
}

Open in new window

0
 

Author Comment

by:Aarsleff
ID: 36538473
The goal are to keep it simple... By that there's no problem for both HR departments (or more countries later) to have access to the http://mysite/employeepictures with the role and All authentificated users to have read access...;)


I move the picture lib to mysite root and just replace the foreach code block with yours and Run the script?
0
 
LVL 16

Expert Comment

by:quihong
ID: 36539409
Pretty much. Please test in a non-production env.

You would probably want to schedule the script.
0
 

Author Comment

by:Aarsleff
ID: 36540649
Thanks ... :D

Am I wrong when i say that the variables in your "fore each" block differs from my original script...? (I am a total NooB to code and syntax..)

You have:

$photoUrl = $portalurl + "/employee photos/" + $profile["EmployeeID"].Value + ".jpg"
   $photoFile = $portalweb.GetFile($photoUrl)

if($photoFile.Exists) {
$profile["PictureURL"].Value = $portalurl + "/photos/" + $profile["EmployeeID"].Value + ".jpg"
$profile.Commit()
}

Open in new window


Could you please adjust it to the complete script code ?

#My Site URL
$mySiteUrl = "http://mysite/"

#The part of the picture URL you are trying to find
$pictureLibUrl = "http://countryA/employesspictures"

#The internal name for PictureURL
$upPictureURLAttribute = "PictureURL"
#The internal name for Login
$LoginAttribute = "AccountName"


#Get site objects and connect to User Profile Manager service
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profiles = $profileManager.GetEnumerator()

<!--foreach ($userProfile in $profiles) {

$userLogin = $userProfile[$LoginAttribute].Value.Split('\')[1]
$newPictureURL = $pictureLibUrl + $userLogin + ".jpg"
$userProfile[$upPictureURLAttribute].Value = $newPictureURL
$userProfile.Commit()-->


foreach ($profile in $upm)
{
$photoUrl = $portalurl + "/employee photos/" + $profile["EmployeeID"].Value + ".jpg"
$photoFile = $portalweb.GetFile($photoUrl)

if($photoFile.Exists) {
$profile["PictureURL"].Value = $portalurl + "/photos/" + $profile["EmployeeID"].Value + ".jpg"
$profile.Commit()
}
else {
$profile["PictureURL"].Value = $null
$profile.Commit()
}
}

write-host "User: " $userLogin " Picture: " $newPictureURL
}

Open in new window


0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question