powershell 在-UPS-SharePoint中导出所有用户配置文件的已定义属性。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 在-UPS-SharePoint中导出所有用户配置文件的已定义属性。相关的知识,希望对你有一定的参考价值。
# ----------------------------------------------
# Author: Romain Blanchard
# Date: 20.06.2012
# Description: Export defined properties of all users profiles in -UPS- SharePoint.
# ----------------------------------------------
# Initialize
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
cls
# Settings
$begindate = Get-date
$logdate = Get-date -format yyyy-M-d
$logfile = "D:\WebAnalyticsResources\DataQualityChecking\SPUsers_Properties_$logdate.csv"
$logfileexist = Test-path $logfile
if ($logfileexist -eq "True"){ remove-item -path $logfile -Confirm:$false }
$siteurl = "http://rbla-sp2010-002/my/"
$mySiteHostSite = Get-SPSite $siteurl
$mySiteHostWeb = $mySiteHostSite.OpenWeb()
$context = Get-SPServiceContext $mySiteHostSite
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$count = 0
# Initialize csv file
write-output "AccountName;FirstName;LastName;DisplayName;PictureURL;Phone;Title;JobTitle;Department;Manager;Ask me About;Email;Mobile;Fax;Company;Address;Zip;City;Country" | out-file -filepath $logfile -append
write-host ""
write-host "----------------------------------"
write-host ""
# Script
$AllProfiles = $profileManager.GetEnumerator()
$numberofprofiles = $profileManager.Count
foreach($profile in $AllProfiles)
{
$AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
$user = $profileManager.GetUserProfile($AccountName)
# User's properties
$firstname = $user["FirstName"].Value
$lastname = $user["LastName"].Value
$name = $user["PreferredName"].Value
$picture = $user["PictureURL"].Value
$workphone = $user["WorkPhone"].Value
$title = $user["Title"].Value
$jobtitle = $user["SPS-JobTitle"].Value
$departement = $user["Department"].Value
$manager = $user["Manager"].Value
$askmeabout = $user["SPS-Responsibility"].Value
$workemail = $user["WorkEmail"].Value
$mobilephone = $user["CellPhone"].Value
$fax = $user["Fax"].Value
$company = $user["Company"].Value
$streetaddress = $user["StreetAddress"].Value
$zipcode = $user["ZipCode"].Value
$city = $user["City"].Value
$country = $user["Country"].Value
write-output "$AccountName;$firstname;$lastname;$name;$picture;$workphone;$title;$jobtitle;$departement;$manager;$askmeabout;$workemail;$mobilephone;$fax;$company;$streetaddress;$zipcode;$city;$country" | out-file -filepath $logfile -append
$count++
$a = ($count / $numberofprofiles)
$b = "{0:P2}" -f $a
Write-Progress -activity "Exporting data to CSV..." -status "Progress: $b"
}
Write-Progress "done" "done" -completed
write-host "Done!" -ForegroundColor Green
write-host ""
write-host "----------------------------------"
$enddate = Get-date
$datediff = (($enddate - $begindate)).ToString()
$mySiteHostSite.Dispose()
write-host ""
write-host "$count users found in $datediff min." -ForegroundColor Green
write-host ""
write-host "----------------------------------"
以上是关于powershell 在-UPS-SharePoint中导出所有用户配置文件的已定义属性。的主要内容,如果未能解决你的问题,请参考以下文章
powershell PowerShell:在PowerShell控制台中更改错误,警告,调试颜色
Powershell:在 PowerShell 中重新加载路径
如何在powershell 运行bat
如何在 powershell 远程会话(powershell)中编辑文件
在powershell-ise中怎么调用powershell中的函数
怎样启动powershell