Solved

Translating AD SID in CSV into DOMAIN\username format ?

Posted on 2013-10-22
6
972 Views
Last Modified: 2013-11-07
Hi People,

Can anyone please assist me with the Powershell script which can translate the last column result of my CSV file into DOMAIN\Ussername format ?

CSV file format:

UserArchived,Archive ID,PermissionType,SID
Trifosa Hanimex, 1A413D4BD6F740E47BAF2A5E5CD1DC11F1110000,0,S-1-5-21-1659004503-287218729-1801674531-18135
Jamela Gunasakira, 1A413D4BD6F740E47BAFAEEE5CD1DC11F1110000,0,S-1-5-21-1659004503-282458629-1801674531-18135
.
.
.
Nadya Samira, 1BCDEF4BD6F740E47BAF2A5E5CD1DC11F1110000,0,S-1-5-21-1659004503-287218729-1801932686-18135

Thanks in advance.
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 500 total points
ID: 39592775
Hope you have win2008 R2 Domain controllers..And If all your user have the same domain name then you can use..

In code replace "Domain" with your domain name..
Import-Module Activedirectory
Import-Csv C:\input.csv | Select *,@{N="UserName";E={$User=Get-ADuser $_.Sid;"Domain\$($User.SamAccountName)"}} | Export-Csv C:\Temp\report.csv -NTI

Open in new window

Else try..
Import-Module Activedirectory
Import-Csv C:\input.csv | Select *,@{N="UserName";E={$User=Get-ADuser $_.Sid;"$( (Get-ADDomain ($user.UserPrincipalName -split "@")[1]).NetBIOSName)\$($User.SamAccountName)"}} | Export-Csv C:\Temp\report.csv -NTI

Open in new window

0
 
LVL 8

Author Comment

by:Senior IT System Engineer
ID: 39592812
Hi subsun,

I'm using Windows Server 2008 instead of R2 :-/
0
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 500 total points
ID: 39592887
Do you have Quest AD PowerShell tools?
http://www.quest.com/powershell/activeroles-server.aspx
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 8

Author Comment

by:Senior IT System Engineer
ID: 39592901
Yes i have that QAD installed
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39592953
Try..
Import-Csv C:\input.csv | Select *,@{N="UserName";E={(Get-QADuser $_.Sid).NTAccountName}} | Export-Csv C:\Temp\report.csv -NTI

Open in new window

0
 
LVL 3

Expert Comment

by:w_richard
ID: 39597239
Thanks for this info. i suppose this was by mistake.

But anyways would keep in mind this info.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question