I'm trying to export groups from my site and I used this script.

$groupName="BWS Team"
$Output = @("GroupName|Name|Login|Email|Department|Title")
$web = Get-SPWeb $siteUrl
$site = $web.Site
$rootWeb = $site.RootWeb
$UserList = $rootWeb.Lists["User Information List"]
$web.SiteGroups[$groupName].Users|%{$user = $UserList.GetItemById($_.ID)
if($user -ne $null)
$JobTitle = $user["JobTitle"]
$Department = $user["Department"]
$Output += ($groupName+"|"+$_.Name+"|"+$_.UserLogin+"|"+$_.Email+"|"+$Department +"|"+$JobTitle)
$Output > "D:\MembersExport.csv"

You cannot call a method on a null-valued expression.
At line:8 char:37
+ $web.SiteGroups[$groupName].Users|%{$user = $UserList.GetItemById($_.ID)
+                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
  • 1
    Can you try replacing the % with ForEach ($user in $UserList)? – ova Aug 24 '16 at 9:01
  • replaced $rootWeb.Lists["User Information List"] with $UserList = $rootWeb.SiteUserInfoList – malibeg Aug 24 '16 at 12:48

To access the UserInformationList you need to directly call for it instead of using <SPWeb>.Lists[<listTitle>] like:

$web = Get-SPWeb $siteUrl
$userList = $web.SiteUserInfoList;
|improve this answer|||||
  • It is SiteUserInfoList, found thanks to intellisense in ISE – malibeg Aug 24 '16 at 12:47
  • @malibeg oh right, changed it in the answer. – garglblarg Aug 24 '16 at 12:50

I ran the same script and it works well. if $UserList is null, that may mean the Title of the User Information List may have been modified. You can confirm that by browsing this Url: http://yoursite/_catalogs/users/simple.aspx. Alternatively, as suggested by @garglblarg, you can use SPWeb.SiteUserInfoList directly.

SPWeb.SiteUserInfoList property

|improve this answer|||||
  • thanks, what was the title of the list? Was it modified? – Nadeem Yousuf Aug 24 '16 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.