locked
Need help in POWERSHELL RRS feed

  • Question

  • Hi, 

    I need some help on below powershell script as i am pretty new to ps.  

    What i would like to achieve is... 

    1.  get SID and respective username in computer.  (i have done this). 

    2.  get a list of SID that can be found in registry in HKEY_USERS  (i have done this)

    3.  compare or match the full list to the SID found in registry_HKEY_USERS then modify a registry key with username of that particular SID.  

    e.g. if SID:  S-1-2-1234567890 and username:  ABC  found match, then modify one of the registry key C:\ABC\Folder

    can someone help me on this part?  Appreciate :) 

    new-psdrive HKU registry HKEY_USERS -ErrorAction silentlycontinue
    $Full = get-wmiobject win32_useraccount
    $SIDs =  $full | ft sid -HideTableHeaders
    $current = gci -path registry::HKEY_USERS -name

    For ($SID in $SIDs)
    { $_ -match $current 
      if match, update the respective FULL name (that found in $full)  into  respective location in registry.  




      







    • Edited by Kitoro Wednesday, August 9, 2017 12:19 PM Typo
    Tuesday, August 8, 2017 3:03 AM

Answers

  • You can translate a user SID to a name in one line.

    ([adsi]'LDAP://<SID=S-1-5-21-1997746983-321388823-153608166-1130>').Name


    \_(ツ)_/

    Tuesday, August 8, 2017 3:14 AM

All replies

  • You can translate a user SID to a name in one line.

    ([adsi]'LDAP://<SID=S-1-5-21-1997746983-321388823-153608166-1130>').Name


    \_(ツ)_/

    Tuesday, August 8, 2017 3:14 AM
  • Hi,
    Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance.

    Best Regards,

    Frank

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Marked as answer by Kitoro Sunday, February 4, 2018 5:33 AM
    • Unmarked as answer by jrv Sunday, February 4, 2018 6:04 AM
    Wednesday, September 6, 2017 7:42 AM