Solved

Translating AD SID in CSV into DOMAIN\username format ?

Posted on 2013-10-22
6
922 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
  • 3
  • 2
6 Comments
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 500 total points
Comment Utility
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 7

Author Comment

by:Senior IT System Engineer
Comment Utility
Hi subsun,

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

Assisted Solution

by:Subsun
Subsun earned 500 total points
Comment Utility
Do you have Quest AD PowerShell tools?
http://www.quest.com/powershell/activeroles-server.aspx
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 7

Author Comment

by:Senior IT System Engineer
Comment Utility
Yes i have that QAD installed
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
Comment Utility
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
Comment Utility
Thanks for this info. i suppose this was by mistake.

But anyways would keep in mind this info.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
This article will help you understand what HashTables are and how to use them in PowerShell.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now