Za .. SharePoint!
SharePoint Tips
Monday, March 24, 2014
Exporting SharePoint User Profiles to CSV Using Powershell
$siteUrl
=
"http://YOUR_HOSTNAME_HERE"
$outputFile
=
"c:\temp\sharepoint_user_profiles.csv"
Add-PSSnapin
Microsoft
.
SharePoint
.
PowerShell
-ErrorAction
SilentlyContinue
$serviceContext
=
Get-SPServiceContext
-Site
$siteUrl
$profileManager
=
New-Object
Microsoft
.
Office
.
Server
.
UserProfiles
.
UserProfileManager
(
$serviceContext
)
;
$profiles
=
$profileManager
.
GetEnumerator
()
$fields
=
@
(
"SID"
,
"ADGuid"
,
"AccountName"
,
"FirstName"
,
"LastName"
,
"PreferredName"
,
"WorkPhone"
,
"Office"
,
"Department"
,
"Title"
,
"Manager"
,
"AboutMe"
,
"UserName"
,
"SPS-Skills"
,
"SPS-School"
,
"SPS-Dotted-line"
,
"SPS-Peers"
,
"SPS-Responsibility"
,
"SPS-PastProjects"
,
"SPS-Interests"
,
"SPS-SipAddress"
,
"SPS-HireDate"
,
"SPS-Location"
,
"SPS-TimeZone"
,
"SPS-StatusNotes"
,
"Assistant"
,
"WorkEmail"
,
"SPS-ClaimID"
,
"SPS-ClaimProviderID"
,
"SPS-ClaimProviderType"
,
"CellPhone"
,
"Fax"
,
"HomePhone"
,
"PictureURL"
)
erty
.
IsMultivalued
)
{
$user
.
$field
=
$profil
$collection
=
@
()
foreach
(
$profile
in
$profiles
)
{
$user
=
""
|
select
$fields
foreach
(
$field
in
$fields
)
{
if
(
$profile
[
$field
].
Prop
e
[
$field
]
-join
"|"
}
else
{
$user
.
$field
=
$profile
[
$field
].
Value
}
}
$collection
+=
$user
}
$collection
|
Export-Csv
$outputFile
-NoTypeInformation
$collection
|
Out-GridView
Reference:
http://www.rigelgroupllc.com/blog/2013/10/14/export-sharepoint-user-profiles-to-csv
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment