Solved

Translating AD SID in CSV into DOMAIN\username format ?

Posted on 2013-10-22
6
942 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
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 7

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 7

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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 process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

912 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

22 Experts available now in Live!

Get 1:1 Help Now