1

I have script who get all users. How can I get information in profile? - about - description - assignement

1
  • 1
    Please share your current script code and also try to clarify your question to avoid it being closed as "Unsure what you're asking" Commented Jun 8, 2015 at 9:50

1 Answer 1

4

If you want to access profile of single user following is the script

$mySiteUrl = "http://mysite"
$adAccount = "DOMAIN\chill"
$upAttribute = "WebSite"
$upAttributeValue = “http://get-spscripts.com”

#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)

#Check to see if user profile exists
if ($profileManager.UserExists($adAccount))
{
    #Get user profile and change the value
    $up = $profileManager.GetUserProfile($adAccount)
    $up[$upAttribute].Value = $upAttributeValue
    $up.Commit()
}
else
{
    write-host "Profile for user"$adAccount "cannot be found"
}

#Dispose of site object
$site.Dispose()

If you want to access all user profile properties

#Get Site for Service context
$Site = Get-SPSite -Limit 1

$ServiceContext = Get-SPServiceContext($Site)

$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)

$Profiles = $ProfileManager.GetEnumerator()    #Load all profiles into array
1
  • 1
    Thanks! And if anyone will get New-Object : Exception calling ".ctor" with "1" argument(s): "UserProfileApplicationNotAvailableException_Logging then setting correct permissions will help: bramdejager.wordpress.com/2013/02/14/… Commented Mar 22, 2018 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.