Link to home
Start Free TrialLog in
Avatar of Montoya
Montoya

asked on

Get user profiles from SharePoint 2010 and put in Excel

Trying to get a list of user profiles from SharePoint 2010.
Ive already tried script at https://onedrive.live.com/?cid=5593AB40F8C855AD&id=5593AB40F8C855AD%213364
and got errors, so I need a different Powershell script or other method to get all existing profiles, preferably into a CSV so I can put in Excel.
ASKER CERTIFIED SOLUTION
Avatar of Jayaraja Jayaraman
Jayaraja Jayaraman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Montoya
Montoya

ASKER

is this a ps1 script?
Avatar of Montoya

ASKER

this script errors out for me..

PS C:\Powershell> .\allusers2
New-Object : Exception calling ".ctor" with "1" argument(s): "Object reference
not set to an instance of an object."
At C:\Powershell\allusers2.ps1:7 char:29
+ $profileManager = New-Object <<<<  Microsoft.Office.Server.UserProfiles.UserP
rofileManager($serviceContext);
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvoca
   tionException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
   Shell.Commands.NewObjectCommand

You cannot call a method on a null-valued expression.
At C:\Powershell\allusers2.ps1:8 char:42
+ $profiles = $profileManager.GetEnumerator <<<< ()
    + CategoryInfo          : InvalidOperation: (GetEnumerator:String) [], Run
   timeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Exporting profiles
Cannot index into a null array.
At C:\Powershell\allusers2.ps1:16 char:40
+    $profileData.AccountName = $profile[ <<<< "AccountName"].Value
    + CategoryInfo          : InvalidOperation: (AccountName:String) [], Runti
   meException
    + FullyQualifiedErrorId : NullArray

Cannot index into a null array.
At C:\Powershell\allusers2.ps1:17 char:38
+    $profileData.FirstName = $profile[ <<<< "FirstName"].Value
    + CategoryInfo          : InvalidOperation: (FirstName:String) [], Runtime
   Exception
    + FullyQualifiedErrorId : NullArray

Cannot index into a null array.
At C:\Powershell\allusers2.ps1:18 char:37
+    $profileData.LastName = $profile[ <<<< "LastName"].Value
    + CategoryInfo          : InvalidOperation: (LastName:String) [], RuntimeE
   xception
    + FullyQualifiedErrorId : NullArray

Cannot index into a null array.
At C:\Powershell\allusers2.ps1:19 char:42
+    $profileData.PreferredName = $profile[ <<<< "PreferredName"].Value
    + CategoryInfo          : InvalidOperation: (PreferredName:String) [], Run
   timeException
    + FullyQualifiedErrorId : NullArray

Cannot index into a null array.
At C:\Powershell\allusers2.ps1:20 char:38
+    $profileData.WorkPhone = $profile[ <<<< "WorkPhone"].Value
    + CategoryInfo          : InvalidOperation: (WorkPhone:String) [], Runtime
   Exception
    + FullyQualifiedErrorId : NullArray

PS C:\Powershell>
Avatar of Montoya

ASKER

I also need to get the user's Title, please.

Thank you for your efforts.
Avatar of Montoya

ASKER

Any suggestions, Layaraja?
yes this is a powershell script .
quick check on the script.....
1. did you run under admin account (farm admin)?
2.Did you change the site collection url ?
and for the ctor error refer here http://blogs.catapultsystems.com/rhutton/archive/2012/10/11/updating-a-user-profile-picture-using-powershell-exception-calling-quote-ctor-quote-with-quote-1-quote-argument.aspx

for title..change it to
  $profileData = "" | select "AccountName","FirstName", "LastName","PreferredName","WorkPhone","Title"
and add one more line
   $profileData.Title= $profile["Title"].Value