导出到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. Windows Azure Virtual Machine (32) 如何在Windows操作系统配置SFTP

    <Windows Azure Platform 系列文章目录> 下载地址:http://files.cnblogs.com/files/threestone/Windows_SFTP.pd ...

  2. Azure REST API (1) 前言

    <Windows Azure Platform 系列文章目录> 一.服务运行时API简介 微软的Windows Azure服务总线提供了一整套REST风格的API,其中包括服务运行时API ...

  3. 探秘重编译(Recompilations)(2/2)

    在上一篇文章里,我讨论了使用临时表如何引起SQL Server里的重编译.在文章最后我提到,今天这篇文章我会聚焦表变量(Table Variables)的更多信息,它可以避免重编译的昂贵开销.我们来详 ...

  4. JavaScript资源大全

    目录 前端MVC 框架和库 包管理器 加载器 打包工具 测试框架 框架 断言 覆盖率 运行器 QA 工具 基于 Node 的 CMS 框架 模板引擎 数据可视化 编辑器 UI 输入 日历 选择 文件上 ...

  5. ASP.NET MVC显示HTML字符串

    一些html经HtmlEncode后,如“<span>测试数据</span>”.现需要把这些内容正常显示于asp.net mvc的视图内. 举个例子来解决与说明,先创建一个mo ...

  6. 将BootstrapJS和AngularJS结合使用以及为什么不用jQuery

    原文网址链接:http://ourjs.com/detail/54e18c51232227083e000034Bootstrap  和 Angular  都是人们大量使用的工具.在很多项目中,它们需要 ...

  7. java的if else语句入门

    条件语句,是程序中根据条件是否成立进行选择执行的一类语句,这类语句在实际使用中,难点在于如何准确的抽象条件.例如实现程序登录功能时,如果用户名和密码正确,则进入系统,否则弹出“密码错误”这样的提示框等 ...

  8. jQuery+CSS3实现404背景动画特效

    效果:http://hovertree.com/texiao/jquery/74/ 源码下载:http://hovertree.com/h/bjaf/ko0gcgw5.htm 效果图如下: 代码如下: ...

  9. Android经典完美退出方法

    Android经典完美退出方法,使用单例模式创建一个Activity管理对象,该对象中有一个Activity容器(具体实现自己处理,使用LinkedList等)专门负责存储新开启的每一个Activit ...

  10. vim 使用说明

    =========================================================本使用说明与 把VIM打造成IDE 配套======================= ...