I have script who get all users. How can I get information in profile? - about - description - assignement
1 Answer
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
-
1Thanks! And if anyone will get
New-Object : Exception calling ".ctor" with "1" argument(s): "UserProfileApplicationNotAvailableException_Loggingthen setting correct permissions will help: bramdejager.wordpress.com/2013/02/14/…Mariusz Ignatowicz– Mariusz Ignatowicz2018-03-22 15:23:21 +00:00Commented Mar 22, 2018 at 15:23