SharePoint 2010: Export User Profile Properties to a Text File or Excel using PowerShell
导出到txt
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
# SharePoint site URL
$site = new-object Microsoft.SharePoint.SPSite("http://contoso.com/");
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);
$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
$AllProfiles = $ProfileManager.GetEnumerator()
$file = New-Object System.IO.StreamWriter "D:\UserProfiles.txt";
$file.Writeline("CustomID|Accountname|PreferredName|UserName|FirstName|LastName|DeskPhoneNo|Department|Title|Manager|WorkEmail|Office|Classification|ServiceDate");
foreach($profile in $AllProfiles)
{
$CustomID = $profile["CustomID"].value
$AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
$PreferredName = $profile["PreferredName"].value
$UserName = $profile["UserName"].value
$FirstName = $profile["FirstName"].value
$LastName = $profile["LastName"].value
$DeskPhoneNo = $profile["DeskPhoneNo"].value
$Department = $profile["Department"].value
$Title = $profile["Title"].value
$Manager = $profile["Manager"].value
$WorkEmail = $profile["WorkEmail"].value
$Office = $profile["Office"].value
$Classification = $profile["Classification"].value
$ServiceDate = $profile["ServiceDate"].value
$file.Writeline($CustomID+"|"+$AccountName+"|"+$PreferredName+"|"+$UserName+"|"+$FirstName+"|"+$LastName+"|"+$DeskPhoneNo+"|"+$Department+"|"+$Title+"|"+$Manager+"|"+$WorkEmail+"|"+$Office+"|"+$Classification+"|"+$ServiceDate);
}
$file.close();
$site.Dispose()
导出到excel
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $siteUrl = "http://sp2010"
$outputFile = "C:\UserProfiles.csv" $serviceContext = Get-SPServiceContext -Site $siteUrl
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
$profiles = $profileManager.GetEnumerator() Write-Host "Exporting profiles" $collection = @()
foreach ($profile in $profiles) { $profileData = "" | select "AccountName","FirstName", "LastName","PreferredName","WorkPhone"
$profileData.AccountName = $profile["AccountName"].Value
$profileData.FirstName = $profile["FirstName"].Value
$profileData.LastName = $profile["LastName"].Value
$profileData.PreferredName = $profile["PreferredName"].Value
$profileData.WorkPhone = $profile["WorkPhone"].Value
$collection += $profileData
} $collection | Export-Csv $outputFile -NoTypeInformation
导出乱码问题
Export-Csv $outputFile -NoTypeInformation -Encoding Unicode
SharePoint 2010: Export User Profile Properties to a Text File or Excel using PowerShell的更多相关文章
- Sharepoint 2010 工作流启动时处理出错
在Sharepoint 2010 中使用Sharepoint 2010 designer做了一个工作流: 运行工作流时,当主办工程师是“张三”的时候,工作流一启动就报错. -------------- ...
- Searching External Data in SharePoint 2010 Using Business Connectivity Services
from:http://blogs.msdn.com/b/ericwhite/archive/2010/04/28/searching-external-data-in-sharepoint-2010 ...
- [SharePoint 2010] 自定义字段类型开发(二)
在SharePoint 2010中实现View Action Button效果. http://www.sharepointblogs.be/blogs/vandest/archive/2008/06 ...
- 为Sharepoint 2010 批量创建SharePoint测试用户
无意搜到下面一篇文章,http://www.cnblogs.com/lambertqin/archive/2012/04/19/2457372.html,原作者写的太"高大上",可 ...
- [原] SharePoint 2010 WebPart与Google地图系列 一:创建显示地图的WebPart
摘要: 作为信息化先驱的产品SharePoint 2010竟然对GIS相关技术支持如此有限,试问现在哪个企业没有大量的项目需要结合Google地图来进行开发,单纯地从Google Javascript ...
- SharePoint 2010 文档管理系列之星级评论功能
前言:正如我们前面介绍的是,文档管理就是让大家更加直观.方便的对手里的文档,进行统筹掌控,哪些文档是有价值的,哪些文档更受大家欢迎,所有就带来了这个星级评论. 当然,这个是SharePoint 201 ...
- “Stamping” PDF Files Downloaded from SharePoint 2010
http://blog.falchionconsulting.com/index.php/2012/03/stamping-pdf-files-downloaded-from-sharepoint-2 ...
- SharePoint 2010 ——自定义上传页面与多文件上传解决方案
最近项目遇到一个很麻烦的问题,原以为很容易解决,结果搞了那么久,先开个头,再慢慢写 SharePoint 2010 ——自定义上传页面与多文件上传解决方案 1.创建Sharepoint空白项目,创建应 ...
- SharePoint 2010 BCS - 概述
博客地址 http://blog.csdn.net/foxdave SharePoint 2010首次引入了BCS的概念 - Business Connectivity Service,即业务连接服务 ...
随机推荐
- 增强学习(四) ----- 蒙特卡罗方法(Monte Carlo Methods)
1. 蒙特卡罗方法的基本思想 蒙特卡罗方法又叫统计模拟方法,它使用随机数(或伪随机数)来解决计算的问题,是一类重要的数值计算方法.该方法的名字来源于世界著名的赌城蒙特卡罗,而蒙特卡罗方法正是以概率为基 ...
- web接口测试之GET与POST请求
关于HTTP协议,我考虑了一下觉得没必要再花一节内容来介绍,因为网上关于HTTP协议的介绍非常详细.本着以尽量避免介绍一空洞了概念与理论来介绍接口测试,我这里仍然会给出具体实例. 在此之前先简单的介绍 ...
- 【Android】Fragment的简单笔记
被虐了,做某公司笔试时,发现自己连个Fragment的生命周期都写不详细.平时敲代码,有开发工具的便利,有网上各大神的文章,就算忘了也很容易的可以查到,但当要自己不借助外界,却发现自己似乎对该知识点并 ...
- Linq查询操作之排序操作
在Linq中排序操作可以按照一个或多个关键字对序列进行排序.其中第一个排序关键字为主要关键字,第二个排序关键字为次要关键字.Linq排序操作共包含以下5个基本的操作. 1.OrderBy操作,根据排序 ...
- 为什么我会选IT【这几年是怎么过来的】
导火线 晚上跟高中同学说我近来的状况,无意中他提到:“如果当初没意外话,今年估计你就是一名老师了吧”.这让我很是怀念以前的日子,这四年来过的很快,开始想着当初是怎么过来的 : 高考 本人英语不佳,高考 ...
- RabbitMQ入门教程——路由(Routing)
绑定( Bindings) 之前的文章中我们已经创建过bindings,代码如下: channel.QueueBind(queue: queueName, exchange: EX ...
- C#使用读写锁三行代码简单解决多线程并发写入文件时线程同步的问题
(补充:初始化FileStream时使用包含文件共享属性(System.IO.FileShare)的构造函数比使用自定义线程锁更为安全和高效,更多内容可点击参阅) 在开发程序的过程中,难免少不了写入错 ...
- 【Java每日一题】20161207
package Dec2016; public class Ques1207 { public static void main(String[] args) { new Test(); new Te ...
- python问题记录
今天才python群里看到一个问题 python2.7: L = [x for x in 'hello'] print L print x python3.4: L = [ x for x in 'h ...
- Java的自动递增和递减
和C 类似,Java 提供了丰富的快捷运算方式.这些快捷运算可使代码更清爽,更易录入,也更易读者辨读.两种很不错的快捷运算方式是递增和递减运算符(常称作"自动递增"和"自 ...