powershell 用户信息列表更改

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 用户信息列表更改相关的知识,希望对你有一定的参考价值。

# If a user has incorrect information showing in their CMDNET user profile in SharePoint this script can correct
# Add their information to the following 3 variables (the Email and Display Name are the only ones users wanted changed so far)

$username = "PSNS\ps***"
$mail = "firstname.lastname@navy.mil"
$displayname = "lastname, firstname"
$jobtitle = " " 

Write-Host "Changing information for $username"

foreach($site in Get-SPSite -Limit ALL)
 {
    $web = $site.RootWeb
    # Loop through all sites collections except the central administration. This allows the code to work on test or prod by not having to use the URL.
    if($web.Url -like "*homeportnw*")
    {
        Write-Host $web.Url
	$list = $web.Lists["User Information List"]
	$query = New-Object Microsoft.SharePoint.SPQuery
	$query.Query = "<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>$username</Value></Eq></Where>" 
	$userInformationListItems = $list.GetItems($query)
		if ($userInformationListItems -ne $null)
			{
				foreach($userInformationListItem in $userInformationListItems)
					{

# Remove the remark from the next line to display which site collections the user exists in and their display name:  
# echo $userInformationListItem["Title"]
# "Title" here is the same as "Name" in User Info List and "EMail" = "Work e-mail" and "Name" = "Account"

# ******* Run these 2 next sections separately ********  
# Remove the remarks from the next 2 lines to change the user's Email:
#					$userInformationListItem["EMail"] = $mail
# 					$userInformationListItem.SystemUpdate()

# Remove the remarks from the next 2 lines to change the user's Display Name:
					$userInformationListItem["Title"] = $displayname
 					$userInformationListItem.SystemUpdate()

# Remove the remarks from the next 2 lines to change the user's Job Title:
#					$userInformationListItem["JobTitle"] = $jobtitle
# 					$userInformationListItem.SystemUpdate()

					}
			} else {
				echo "Not in this site collection"
			       }
     }
}

以上是关于powershell 用户信息列表更改的主要内容,如果未能解决你的问题,请参考以下文章

PowerShell 和 TFS |使用本地路径与使用服务器路径的 PowerShell ISE 从 TFS 获取更改集列表

powershell 仅更改列表的列表视图阈值,而不是整个Web应用程序。

如何使用PowerShell获取物理磁盘的信息

如何通过Powershell代码更改特定WPF列表框项的背景颜色?

powershell 更改列表项而不更改修改的by和date并且不触发spitem事件接收器的示例。

我想用 powershell 显示主板信息但更改参数名称输出