惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Security Archives - TechRepublic
Security Archives - TechRepublic
Forbes - Security
Forbes - Security
C
Cyber Attacks, Cyber Crime and Cyber Security
Latest news
Latest news
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Vercel News
Vercel News
V
Vulnerabilities – Threatpost
I
InfoQ
GbyAI
GbyAI
有赞技术团队
有赞技术团队
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
F
Full Disclosure
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
Hugging Face - Blog
Hugging Face - Blog
Simon Willison's Weblog
Simon Willison's Weblog
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
Engineering at Meta
Engineering at Meta
The Register - Security
The Register - Security
T
Tor Project blog
T
Troy Hunt's Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Security Affairs
W
WeLiveSecurity
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Stack Overflow Blog
Stack Overflow Blog
Apple Machine Learning Research
Apple Machine Learning Research
H
Heimdal Security Blog
S
Secure Thoughts
Y
Y Combinator Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Security Latest
Security Latest
Martin Fowler
Martin Fowler
G
Google Developers Blog
宝玉的分享
宝玉的分享
腾讯CDC
TaoSecurity Blog
TaoSecurity Blog
T
Threatpost
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Project Zero
Project Zero
Blog — PlanetScale
Blog — PlanetScale
大猫的无限游戏
大猫的无限游戏
MongoDB | Blog
MongoDB | Blog

博客园 - 举重-若轻

Survey 2遍的解决办法 Error occurred in deployment step 'Activate Features': Feature with Id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' is not installed in this farm using powershell to change the some sub-webs' system master page AssetUrlSelector export to excel create a 全局临时表 Generate a random integrater Remote Debugging GAC'd Assemblies in SharePoint get all user profiles redirecting to custom user profile page css的em概念 异步调用的一个例子 .NET种Json时对单引号和特殊字符串的处理 CSS备忘 SharePoint 资料 Server.MapPath方法的应用方法 JSON的客户端和服务器操作 jquery 参考材料 备忘 用powershell更新user的display name
用powershell更新user profile service中的一个字段
举重-若轻 · 2012-12-22 · via 博客园 - 举重-若轻

http://blog.karstein-consulting.com/2010/12/23/read-and-write-user-profile-properties-of-sharepoint-2010-user-profile-service-application-with-powershell/

I needed to change some properties of user profiles of my SharePoint 2010 farm.

Of cource I wanted to do this with PowerShell!

Before you can execute the following script, be sure that your user account is “Admin” on your “User Profile Service Application” and has “Full Control” permissions on the same Service App! – You may get this error: New-Object : Exception calling ".ctor" with "1" argument(s): "No User Profile Application available to service the request. Contact your farm administrator." – You can verify or change this settings in the Central Administration –> Manage Service Applications –> (select User Profile Service Application) –> than:

  1. Click “Administrators” –> Add the user that will execute the PowerShell script –> Set “Full Control” for this user –> Click “OK”
  2. Click “Permissions” –> Add the user that will execute the PowerShell script –> Set “Full Control” for this user –> Click “OK”

So…

Here is the Script for reading properties from the profile system:

#region Check x64 host
if( [System.IntPtr]::Size -ne 8) {
  Write-Error "Please use a x64 PowerShell host!"
  return
}
#endregion

#region Load SharePoint SnapIn and DLL
  Remove-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  
  [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null    
  
  #Check available SharePoint Cmdlets  if( (Get-Command -Noun SPWeb*) -eq $null ) {
    Write-Error "SharePoint SnapIn not loaded. SharePoint cmdlets missing!"
    return
  }
#endregion

#User must be set as Full Control *Admin* and with Full Control *Permission* on Central Admin->Manager Service Application->User Profiler Service App!!
$site=(Get-SPSite "http://sharepoint.local")
$sc = [Microsoft.Office.Server.ServerContext]::GetContext($site)

$upm = New-Object "Microsoft.Office.Server.UserProfiles.UserProfileManager" -ArgumentList ($sc)
$enumerator = $upm.GetEnumerator()
$enumerator.Reset()
while( $enumerator.MoveNext() -eq $true ) {
  $currentUserProfile = $enumerator.Current
  $propertiesCollection = $currentUserProfile.ProfileManager.PropertiesWithSection
  if( $currentUserProfile -ne $null -and $propertiesCollection -ne $null ) {
    foreach($p in $propertiesCollection) {
      Write-Output $p.Name $currentUserProfile[$p.Name].Value
    }
    
    #write to a property:    #$currentUserProfile["FirstName"].Value="Test"    #$currentUserProfile.Commit()  }
}

If you need to write property values than uncomment the two lines on the bottom of the script and change them.