导出到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的更多相关文章

  1. Sharepoint 2010 工作流启动时处理出错

    在Sharepoint 2010 中使用Sharepoint 2010 designer做了一个工作流: 运行工作流时,当主办工程师是“张三”的时候,工作流一启动就报错. -------------- ...

  2. 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 ...

  3. [SharePoint 2010] 自定义字段类型开发(二)

    在SharePoint 2010中实现View Action Button效果. http://www.sharepointblogs.be/blogs/vandest/archive/2008/06 ...

  4. 为Sharepoint 2010 批量创建SharePoint测试用户

    无意搜到下面一篇文章,http://www.cnblogs.com/lambertqin/archive/2012/04/19/2457372.html,原作者写的太"高大上",可 ...

  5. [原] SharePoint 2010 WebPart与Google地图系列 一:创建显示地图的WebPart

    摘要: 作为信息化先驱的产品SharePoint 2010竟然对GIS相关技术支持如此有限,试问现在哪个企业没有大量的项目需要结合Google地图来进行开发,单纯地从Google Javascript ...

  6. SharePoint 2010 文档管理系列之星级评论功能

    前言:正如我们前面介绍的是,文档管理就是让大家更加直观.方便的对手里的文档,进行统筹掌控,哪些文档是有价值的,哪些文档更受大家欢迎,所有就带来了这个星级评论. 当然,这个是SharePoint 201 ...

  7. “Stamping” PDF Files Downloaded from SharePoint 2010

    http://blog.falchionconsulting.com/index.php/2012/03/stamping-pdf-files-downloaded-from-sharepoint-2 ...

  8. SharePoint 2010 ——自定义上传页面与多文件上传解决方案

    最近项目遇到一个很麻烦的问题,原以为很容易解决,结果搞了那么久,先开个头,再慢慢写 SharePoint 2010 ——自定义上传页面与多文件上传解决方案 1.创建Sharepoint空白项目,创建应 ...

  9. SharePoint 2010 BCS - 概述

    博客地址 http://blog.csdn.net/foxdave SharePoint 2010首次引入了BCS的概念 - Business Connectivity Service,即业务连接服务 ...

随机推荐

  1. Testing - 测试基础 - 概念

    测试是为了度量和提高被测试软件的质量,对测试软件进行工程设计.实施.维护的的整个生命周期过程. 仅仅发现Bug是测试的初步,而分析出根本原因推动问题的解决,却要有很深的功底. 不同的测试岗位从事不同的 ...

  2. Windows Azure Service Bus (1) 基础

    <Windows Azure Platform 系列文章目录> 我们在基于Windows Azure进行云端开发的时候,云端的软件通常都需要与其他软件进行交互.这些其他软件可能包括其他In ...

  3. CNN 笔记3

  4. Theano入门神经网络(四)

    这一部分主要介绍用Theano 实现softmax函数. 在多分类任务中经常用到softmax函数,首先上几个投影片解释一下 假设目标输出是y_hat ,激活函数后的Relu y 一个是1.2 一个是 ...

  5. Chrome开发者工具详解(3)-Timeline面板

    Chrome开发者工具详解(3)-Timeline面板 注: 这一篇主要讲解面板Timeline,参考了Google的相关文档,主要用于公司内部技术分享.. Timeline面板 Timeline面板 ...

  6. LINQ多个操作嵌套实现

    获取集合,需要使用多个条件Where,排序OrderBy,查询Select一起. 先来分步实现: source code: string[] stringArray = { "hgdgh&q ...

  7. Windows 7专业版安装VS2005与WinCE6.0开发环境

    近期更新了自己的小黑从XP更新到WIN7专业版,我花了两天时间验证了下列软件安装在WIN7 PRO是完全兼容的. 1:2011年最新更新的SourceInsight3.50.0066版本,这个是支持W ...

  8. hangfire+bootstrap ace 模板实现后台任务管理平台

    前言 前端时间刚开始接触Hangfire就翻译了一篇官方的教程[翻译+山寨]Hangfire Highlighter Tutorial,后来在工作中需要实现一个异步和定时执行的任务管理平台,就结合bo ...

  9. ASP.NET MVC 网站开发总结(三) ——图片截图上传

    本着简洁直接,我们就直奔主题吧,这里需要使用到一个网页在线截图插件imgareaselect(请自行下载). 前台页面: <!DOCTYPE html> <html> < ...

  10. Web.config配置文件详解

    整理了一下ASP.NET Web.config配置文件的基本使用方法.很适合新手参看,由于Web.config在使用很灵活,可以自定义一些节点.所以这里只介绍一些比较常用的节点. <?xml v ...