We have a bool: User profile property.
Is there a way to set the value of this field to 'false' for all users?
The user profile property exists only in the SharePoint and not in AD.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityWe have a bool: User profile property.
Is there a way to set the value of this field to 'false' for all users?
The user profile property exists only in the SharePoint and not in AD.
You can iterate through all user profiles and update them. The PowerShell script can look like this:
[void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server");
Add-PSSnapin Microsoft.SharePoint.PowerShell
$site=Get-SPSite "https://yourSitecCollection"
$serviceContext = Get-SPServiceContext $site;
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
$userProfile = $upm.GetUserProfile("myarlett@company.com");
foreach($userProfile in $upm)
{
$userProfile["PropertyName"].Value = "Test Value";
$userProfile.Commit()
}
You can try something like this,
Get-ADUser -Filter * -SearchBase "ou=TestOU,dc=domainController01,dc=com" | Set-ADUser -customProperty $true
OR
# Get all users in the SomeOU.
$AllUsers = Get-ADUser -Filter * -SearchBase "OU=ChangeMeOU,OU=UserAccounts,DC=DomainController01,DC=COM"
# Iterate the users and update the department and title attributes in AD.
foreach($oUser in $AllUsers)
{
# Update properties.
$oUser.department = "Finance"
$oUser.title = "Analyst 1"
# Update the user data in AD using the Instance parameter of Set-ADUser.
oUser.CustomProperty = "WhateverYouWantHere"
Set-ADUser -Instance $oUser
}
[void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server");
Add-PSSnapin Microsoft.SharePoint.PowerShell
$site=Get-SPSite "http://site:8080"
$serviceContext = Get-SPServiceContext $site;
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
$profiles = $upm.GetEnumerator()
foreach($userProfile in $profiles)
{
write-host $userProfile["AccountName"]
write-host $($userProfile["AboutMe"])
write-host $($userProfile["Matricule"])
write-host "Telephone :" $($userProfile["HomePhone"])
$userProfile["AboutMe"].Value = "Matricule: "+ $userProfile["Matricule"].Value+", Tel: "+ $userProfile["HomePhone"].Value;
$userProfile.Commit()
}