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,即业务连接服务 ...
随机推荐
- 谷歌插件Image downloader开发之 content script
自己运营了一个公众号,在发文章的时候,需要在网上找一些图,而有些网站的图片可能隐藏在属性或者背景图中,要下载的时候经常审查元素,查看源码,不太方便,最近在看一些谷歌插件的api,便顺手做了一个插件Im ...
- bootbox上的浮层弹出如何加上datepicker
bootbox和datepicker都是插件,我想要做的需求大致长这样: 我希望使用bootbox弹出的对话框中能弹出一个截止时间的选择框,这个选择框使用datepicker来做. 看了下这个帖子: ...
- 基于HT for Web的3D拓扑树的实现
在HT for Web中2D和3D应用都支持树状结构数据的展示,展现效果各异,2D上的树状结构在展现层级关系明显,但是如果数据量大的话,看起来就没那么直观,找到指定的节点比较困难,而3D上的树状结构在 ...
- Ionic2学习笔记(0):HelloWorld
作者:Grey 原文地址:http://www.cnblogs.com/greyzeng/p/5529153.html 操作系统: Windows 10 环境配置: Node.js Java SE D ...
- C#如何调用COM
这章中描述的属性被用在创建和COM程序交互的程序中. 1.1 COMImport 属性 当被放在一个类上, COMImport 属性就把这个类标记为一个外部实现的COM 类.这样的一个类声明使得可以 ...
- STM32L系列单片机内部EEPROM的读写
STM32L系列单片机内部提供了EEPROM存储区域,但实质上,其FLASH也是EEPROM类型,只不过有一块区域被开放出来专门用作EEPROM操作而已.STM32L的EEPROM使用寿命设计为100 ...
- 【转】Key/Value之王Memcached初探:一、掀起Memcached的盖头来
一.Memcached是何方神圣? 在数据驱动的Web开发中,经常要重复从数据库中取出相同的数据,这种重复极大的增加了数据库负载.缓存是解决这个问题的好办法.但是ASP.NET中的HttpRuntim ...
- 使用 TOP 限制更新的数据
可以使用 TOP 子句来限制 UPDATE 语句中修改的行数.当 TOP (n) 子句与 UPDATE 一起使用时,将针对随机选择的 n 行执行删除操作.例如,假设您要为一位高级销售人员减轻销售负担, ...
- 在Windows Phone 8中使用Live Connect并保持登陆状态
Live Connect可以让各种客户端访问Live账号.获取好友列表.访问One Drive的文件等,官方地址在此:http://msdn.microsoft.com/zh-cn/live/ff51 ...
- JS虚拟键盘
由于是触摸屏,所以需要一款JS虚拟键盘.上网找了一个好用的VirtualKeyboard,作了修改. 修改该插件参考的博客文章:http://www.cnblogs.com/xinggong/arch ...