getent passwd which works for unprefixed Windows user names with both local and domain users?

Bill Stewart bstewart@iname.com
Tue Dec 10 20:21:41 GMT 2024


On Tue, Dec 10, 2024 at 6:37 AM Cedric Blancher wrote:

We have a Win10 env with mixed local and domain accounts.
> We cannot lookup up local AND domain users with just the plain
> username from Windows. Instead we have to do lookups twice:
>

I don't know the Cygwin solution, but here's a short PowerShell function
that will do it:

function Resolve-AccountName {
  param(
      [Parameter(Mandatory)]
      [Security.Principal.NTAccount]
      $name
  )
  $sid = $name.Translate([Security.Principal.SecurityIdentifier])
  if ( $null -ne $sid ) {
    $sid.Translate([Security.Principal.NTAccount]).Value
  }
}


More information about the Cygwin mailing list