INFORMATICS

The Best

Przełącznik języka

Zaproś mnie na KAWE

Jeżeli podoba Ci się strona i chcesz wspomóc projekt!

Postaw mi kawę na buycoffee.to

This Site

Płatnik

CMS

Hardware

Uncategorised

Emulators

Powershell

Storage Array

DNS

Antivirus program

Licznik

3.png0.png4.png3.png1.png7.png3.png
Today832
Yesterday1238
This week8055
This month18074
Total3043173

Visitor Info

  • IP: 18.190.176.176
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

1
Online

sobota, 23 listopad 2024 19:02

PowerShell Script to convert SID to Domain User

Gwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywna
 

PowerShell Script to convert SID to Domain User

#=========================================================================== 
# Pre-requisite : SID.txt is the text file containing SID's to be resolved 
# Output File   : UID.txt 
#=========================================================================== 
Out-File UID.txt 
foreach ($SID in (Get-Content SID.txt)) 
{ 
    $objSID = New-Object System.Security.Principal.SecurityIdentifier ($SID) 
    Try 
    { 
        $objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) 
        $objUser.Value >>UID.txt 
    } 
    Catch 
    { 
        $SID >>UID.txt 
    } 
} 



-----
another script for Convert Group/User Name to SID:

Syntax:

  $Name = “Group or User Name” 

 (New-Object System.Security.Principal.NTAccount($Name)).Translate([System.Security.Principal.SecurityIdentifier]).value

-------
or
$user ='TestDomainMorgan'
$objUser = New-Object System.Security.Principal.NTAccount($user)
$objSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
Write-Host "Resolved user's sid: " $objSID.Value




another script for Convert SID to Group/User Name:

Syntax:

$Name = “SID ID” 

 (New-Object System.Security.Principal.SecurityIdentifier($Name)).Translate([System.Security.Principal.NTAccount]).value


-----------

or

$SID ='S-1-5-21-1924530255-1943933946-939161726-500'
$objSID = New-Object System.Security.Principal.SecurityIdentifier($SID)
$objUser = $objSID.Translate([System.Security.Principal.NTAccount])
Write-Host "Resolved user name: " $objUser.Value

------------------------

 

Search