Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1040
  • Last Modified:

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.
0
Senior IT System Engineer
Asked:
Senior IT System Engineer
  • 3
  • 2
3 Solutions
 
SubsunCommented:
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
 
SubsunCommented:
Do you have Quest AD PowerShell tools?
http://www.quest.com/powershell/activeroles-server.aspx
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
Senior IT System EngineerIT ProfessionalAuthor Commented:
Yes i have that QAD installed
0
 
SubsunCommented:
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
 
w_richardCommented:
Thanks for this info. i suppose this was by mistake.

But anyways would keep in mind this info.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now