Translating AD SID in CSV into DOMAIN\username format ?

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.
LVL 8
Senior IT System EngineerIT ProfessionalAsked:
Who is Participating?
 
SubsunConnect With a Mentor Commented:
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
 
SubsunConnect With a Mentor Commented:
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
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
Hi subsun,

I'm using Windows Server 2008 instead of R2 :-/
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
SubsunConnect With a Mentor Commented:
Do you have Quest AD PowerShell tools?
http://www.quest.com/powershell/activeroles-server.aspx
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
Yes i have that QAD installed
0
 
w_richardCommented:
Thanks for this info. i suppose this was by mistake.

But anyways would keep in mind this info.
0
All Courses

From novice to tech pro — start learning today.