SharePoint 2010/2013 Powershell: Get SP User Properties of all the Site User or a Using Loginname

Here is how you fetch  user properties/info using powershell. Normally to do that we use the following Powershell command but this required a SPUserPipeBind user identity which looks like this i:0#.w|domain\username

Get-SPUser [[-Identity] ] -Web  [-AssignmentCollection ] [-Group ] [-Limit ]

But incase you dont have SPUserPipeBind you can use the following script.

Now here comes the compelete script which took me couple of hours to build. For instance you are required to fetch all the users of the site along with their managers, following script is going to do the magic for you. What it does is to
  • Fetch all the User of a specific site collection.  
  • Loop through all the user and fetch each user's Manager 
  • Using $web.EnsureUser fetches Manager's Display name since Login Name is not that user friendly. 
  • At the end it takes all the users along with their respective Managers and sends them to a text file.
  • Since the user names were in german in my case so the text file was encoded to  [System.Text.Encoding]::Unicode. You can leave out the third argument while outputting things to text file if you don't need that. 


Disclaimer: I don't completely own this script and the bad new is that I could not keep track of all the sources I followed. Still following are few of them:

http://stackoverflow.com/questions/3896258/how-to-output-text-without-newline-in-powershell
http://blog.incworx.com/blog/sharepoint-administrators-blog/get-a-users-id-using-powershell
http://sharepoint.stackexchange.com/questions/92017/get-user-by-loginname-using-powershell



Vaqar Hyder
E: vaqar.hyder3567@gmail.com
A:
Siebenbürgen Straße 2/1, Korntal-Münchingen, 70825, PK
Hire me on Freelancer.com

Comments

Post a Comment

Popular posts from this blog

SharePoint 2010 Migration Woes: Importing and exporting lists template between different SP2010 Servers

How to Stop People From Reading Your Mind and Judging You

Powershell: Filling up an Existing Excel Sheet with data from SQL Server