Aarsleff
asked on
PictureURL
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:
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....
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
}
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....
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.
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.. )
As long as both web apps are subscribed to the User Profile App, yes.
ASKER
They are ... so that's the solution then... thanks... ;)
So I'll just change the script to?:
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"
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.
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()
}
}
ASKER
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?
I move the picture lib to mysite root and just replace the foreach code block with yours and Run the script?
Pretty much. Please test in a non-production env.
You would probably want to schedule the script.
You would probably want to schedule the script.
ASKER
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:
Could you please adjust it to the complete script code ?
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()
}
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
}