Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

How to list Windows users with Powershell

25 September,2019 by Tom Collins

Question: How can I use Powershell to list out Windows users? Are there Powershell cmdlets which can report on Windows users ?

Answer: There are "out of the box" Powershell cmdlets which will support the requirement . How you apply the powershell cmdlets will depend on how much detail is required.

Here are some examples:

--return local groups

Get-localgroup

--return all members of a group - in this example the Administrator group

Get-LocalGroupMember -Group "Administrators"

--Get the local users 

Get-Local User

--SID of a local group 

(Get-Localgroup Administrators).SID

 

These are some basic examples to extract Windows users information with Powershell. To get other examples of any of the powershell cmdlets use the Examples filter on the powershell cmdlet Get-Help. Here is an example:

Get-Help Get-LocalGroupMember -Examples

 

To integrate these cmdlets with other aspects of managing servers with Powershell use of these Powershell Scripts 

 


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to list Windows users with Powershell


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer